Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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  
dpb

Posts: 8,187
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]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.