Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: SWITCH expression ERROR !!!!
Posted:
Jan 23, 2013 10:01 AM
|
|
"Serhat " <serhat_idd@hotmail.com> wrote in message news:kdn5ag$3mq$1@newscl01ah.mathworks.com... > Hi, > > I want to plot 3 graphics successively. So I use this code: > > for h=1:3 > switch h > case 1 > semilogy(x, y, 'rx-') > case 2 > semilogy(x, y, 'bo-') > case 3 > semilogy(x, y, 'md-') > end > > but it gives this message "" SWITCH expression must be a scalar or string > constant." > > What can I do? Thanks in advance:)
Executing this code on sample x and y data with the following lines to end the FOR loop:
pause % so I can see each plot end
ran without any error on my machine. Therefore there's something you're not showing the group that's contributing or causing this failure.
Set an error breakpoint then run your code.
http://www.mathworks.com/help/matlab/matlab_prog/debugging-process-and-features.html
When MATLAB stops, take a look at the variables in the workspace and what's written on the line of code where it stops. If that doesn't indicate to you the cause of the problem, show the group the line on which MATLAB stopped in context (ideally simplified down; please don't post 100 lines of code) along with information about the specific line on which MATLAB stopped.
-- Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
|
|
|