"Serhat " <email@example.com> wrote in message news:firstname.lastname@example.org... > 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.
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.