f



Error" "he output arguments of the returned function not assigned"

Hello,

    I have been experiencing the following error when I return multiple arguments from a program that the output arguments of the returned function not assigned during the call to the program.  All the output arguments are calculated within the function properly. I believe this is a simple mistake but I cannot see it. Why am I getting this error?

    Thank you.

Cem

The Error
-------------------------------------------
tTestN ('CTestasc',2)

??? Output argument "a" (and maybe others) not assigned during call to "C:\tTestN.m (tTestN)".

Error in ==> tTestN at 9
thresh = [];

Error in ==> tTestN at 46
[a,b,c,d,e,f,g]=tTestN(x,y,z,params,fc,fplot,fgsave,fName,ROI_option);

--------------------------------
The Test Program
--------------------------------

function tTestN(pcf,ROI_option)

[a,b,c,d,e,f,g]=TumorN(x,y,z,params,fc,fplot,fgsave,fName,ROI_option);

sprintf('V = %.4f',a/1000)

--------------------------------
THe function that the test program calls
---------------------------------------

function [a,b,c,d,e,f,g] = TumorN(x,y,z,params,fc,fplot,fgsave,fName,ROI_option)

....

    if (cVolume ~= 0)
%%% METRICS
%%% Add area measurement to this plot 11/5/09
        [geom, iner, cpmo] = polygeom(xedge(ei), yedge(ei));
        % Volume
        a=cVolume;
        % Area
        b=geom(1);
        % Major Axis Length
        major=regionprops(bwlabel(DTpoly),'MajorAxisLength');
        b=major.MajorAxisLength*(X1(2,1)-X1(1,1));
        % Minor Axis Length
        minor=regionprops(bwlabel(DTpoly),'MinorAxisLength');
        c=minor.MinorAxisLength*(Y1(1,2)-Y1(1,1));
        % Equivalent Diameter=sqrt(4*Area/pi)
         d=sqrt(4*b/pi);
        % Perimeter Length
        c=geom(4);
        % Roundness = 4*pi*Area/Perimeter^2
        d=4*pi*b/c^2;
    end;

....
0
Cem
4/8/2010 7:56:06 PM
comp.soft-sys.matlab 211264 articles. 25 followers. lunamoonmoon (257) is leader. Post Follow

4 Replies
1421 Views

Similar Articles

[PageSpeed] 34

Well apparently when you call this thing, cVolume is zero, thus it
never gets into the "if" block and "a" never gets assigned, thus it
can't return "a" as it is required to do.  You could simply initialize
all return arguments immediately upon entering the function so they'll
always have at least SOMETHING for a value.


0
ImageAnalyst
4/8/2010 7:59:51 PM
On Apr 9, 7:59=A0am, ImageAnalyst <imageanal...@mailinator.com> wrote:
> Well apparently when you call this thing, cVolume is zero, thus it
> never gets into the "if" block and "a" never gets assigned, thus it
> can't return "a" as it is required to do. =A0You could simply initialize
> all return arguments immediately upon entering the function so they'll
> always have at least SOMETHING for a value.

And just some gratuitous advice on coding:
When you have many individual scalars to return, a better practice is
to put them into a structure:
v.a=3DcVolume;
v.b=3Dgeom(1);
etc

Then you call with just one output argument:
v=3DTumorN(x,y,z,params,fc,fplot,fgsave,fName,ROI_option);
which is easier to maintain if you change the number of output data at
some later date.
0
TideMan
4/8/2010 8:45:47 PM
ImageAnalyst <imageanalyst@mailinator.com> wrote in message <fba84fcd-76b6-44d0-86fb-7d2e01251c78@z6g2000yqz.googlegroups.com>...
> Well apparently when you call this thing, cVolume is zero, thus it
> never gets into the "if" block and "a" never gets assigned, thus it
> can't return "a" as it is required to do.  You could simply initialize
> all return arguments immediately upon entering the function so they'll
> always have at least SOMETHING for a value.
> 

No. It was the fact that the arguments in the function were not transferred to calling function. So I found the problem.  Thank you.  
0
Cem
4/8/2010 8:50:29 PM
TideMan <mulgor@gmail.com> wrote in message <f36e78d8-1b87-428e-9eee-42831f749070@i37g2000yqn.googlegroups.com>...
> On Apr 9, 7:59 am, ImageAnalyst <imageanal...@mailinator.com> wrote:
> > Well apparently when you call this thing, cVolume is zero, thus it
> > never gets into the "if" block and "a" never gets assigned, thus it
> > can't return "a" as it is required to do.  You could simply initialize
> > all return arguments immediately upon entering the function so they'll
> > always have at least SOMETHING for a value.
> 
> And just some gratuitous advice on coding:
> When you have many individual scalars to return, a better practice is
> to put them into a structure:
> v.a=cVolume;
> v.b=geom(1);
> etc
> 
> Then you call with just one output argument:
> v=TumorN(x,y,z,params,fc,fplot,fgsave,fName,ROI_option);
> which is easier to maintain if you change the number of output data at
> some later date.

Thank you. This is a very gratuitous advice and well taken.
0
Cem
4/9/2010 5:25:05 PM
Reply: