Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: GUI function output problem
Posted:
Jan 28, 2013 10:07 AM
|
|
"George Bedford" <g.bedford@lboro.ac.uk> wrote in message news:ke5pfo$2c5$1@newscl01ah.mathworks.com... > 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.
*snip*
> % 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 slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
|
|
|