??? Error: The expression to the left of the equals sign is not a valid target for an assignment.

1 view (last 30 days)
if obj=L;
[y fs]=wavread('tl.wav');
player=audioplayer(y,fs);
play(player)
else if obj=R;
[y fs]=wavread('tr.wav');
player=audioplayer(y,fs);
play(player)
else if obj=F;
[y fs]=wavread('mf.wav');
player=audioplayer(y,fs);
play(player)
else if obj=B;
[y fs]=wavread('mb.wav');
player=audioplayer(y,fs);
play(player)
else
[y fs]=wavread('s.wav');
player=audioplayer(y,fs);
play(player)
end
end
end
end
end

Accepted Answer

Orion
Orion on 22 Oct 2014
Edited: Orion on 22 Oct 2014
Hi,
your else if (in C code) conditions are badly written -> elseif in matlab code.
and the conditions are not conditions. you need to use == instead of =.
something like
if obj==L;
[y,fs]=wavread('tl.wav');
player=audioplayer(y,fs);
play(player)
elseif obj==R;
[y,fs]=wavread('tr.wav');
player=audioplayer(y,fs);
play(player)
elseif obj==F;
[y,fs]=wavread('mf.wav');
player=audioplayer(y,fs);
play(player)
elseif obj==B;
[y,fs]=wavread('mb.wav');
player=audioplayer(y,fs);
play(player)
else
[y,fs]=wavread('s.wav');
player=audioplayer(y,fs);
play(player)
end

More Answers (0)

Categories

Find more on Simscape Electrical in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!