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: Displaying messages
Replies: 1   Last Post: Mar 6, 2013 2:21 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  

Posts: 9,850
Registered: 6/7/07
Re: Displaying messages
Posted: Mar 6, 2013 2:21 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 3/6/2013 12:21 PM, Achchuthan Ganeshanathan wrote:

> ... am writing a function which has an IF function included in
> it, I am trying to display messages at each stage. but I seem to be
> struggling with it. ...
> function [ output_args ] = Newfunction( velocity )

> if (cond) velocity >= 120;

What's cond? If testing on velocity, then simply

if velocity >= 120;
h=msgbox('Your speed is okay');
> else if velocity >=100 & velocity <=100;

'elseif' is a keyword; 'else if' is another else construction
Fixing that still leaves a problem--velocity can't ever be both > _and_
< 100 at the same time so the only time that can be satisfied is for the
single case of velocity = 100 exactly.

Perhaps the second 100 is a typo for 120 but in that case the <= should
be just < to make the two cases non-overlapping at exactly 120.

> h=msgboc('Warning:Approaching Stall');
> else
> h=msgbox('STALL');
> end
> end

I'd also suggest looking at the CASE construct for another way to
construct such multiple logic...


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.