The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: SWITCH expression ERROR !!!!
Replies: 6   Last Post: Jan 23, 2013 10:01 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 18,038
Registered: 12/7/04
Re: SWITCH expression ERROR !!!!
Posted: Jan 23, 2013 10:01 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Serhat " <> wrote in message
> 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

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.

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
To contact Technical Support use the Contact Us link on

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.