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: GUI function output problem
Replies: 1   Last Post: Jan 28, 2013 10:07 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Steven Lord

Posts: 18,038
Registered: 12/7/04
Re: GUI function output problem
Posted: Jan 28, 2013 10:07 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"George Bedford" <> wrote in message
> Hi,
> I'm still an absolute novice at Matlab and I'm trying to build multiple
> GUI's for data collection, calibration and processing. I'm currently
> having a problem calling a piecewise function to plot using a check box; I
> keep receiving the same error message...
> "Output argument "y" (and maybe others) not assigned during call to
> "C:\.....\BlankSlate.m>pwf"."
> ... and I'm not sure why as it does occasionally work.

That suggests you have at least one code path through your function that
assigns values to all your output arguments and at least one code path
through your function that does not.


> % Apply variables to function
> if x < A1
> y = 0;
> elseif A1 <= x & x < B1
> y =(-cos(pi*(x-A1)/(B1-A1)))*(1/2)+0.5;
> elseif B1 < x & x <= C1
> y = 1;
> elseif C1 < x & x <= D1
> y =(-cos(pi*(x-C1)/(D1-C1)+pi))*(1/2)-0.5+1;
> elseif D1 < x
> y = 0;
> end

If none of these conditions are satisfied then y will not be assigned a
value. It may look like this covers everything, but this assumes x is not
NaN and x is not exactly equal to B1 (assuming C1 > B1.)

One way to detect this would be to assign y the value NaN BEFORE this
IF/ELSE section. You could then check if isnan(y) at the end of the function
and use KEYBOARD to allow you to investigate why y was not assigned a value.

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.