From: Karst on
NPV(p1,p2) is my sub-function which gives me two outputs[x,y]
I have to call this function three times in my main function, see code below:

[v1,v2]=NPV(p1,p2);
[v3,v4]=NPV(p1-epsilon,p2);
[v5,v6]=NPV(p1,p2-esilon);

gradient1=v1-v3;
gradient2=v2-v6;

matlab codes complain that I did not use v2&v5 which is not needed in my main function calculation. Is there a way to avoid the complain?

I tried to use
[v3,]=NPV(p1-epsilon,p2);
[,v6]=NPV(p1,p2-esilon);
but it still complains.

Many thanks in advance for your help.
From: Andy on
"Karst " <xiaoziliu(a)yahoo.com> wrote in message <i43m8h$21i$1(a)fred.mathworks.com>...
> NPV(p1,p2) is my sub-function which gives me two outputs[x,y]
> I have to call this function three times in my main function, see code below:
>
> [v1,v2]=NPV(p1,p2);
> [v3,v4]=NPV(p1-epsilon,p2);
> [v5,v6]=NPV(p1,p2-esilon);
>
> gradient1=v1-v3;
> gradient2=v2-v6;
>
> matlab codes complain that I did not use v2&v5 which is not needed in my main function calculation. Is there a way to avoid the complain?
>
> I tried to use
> [v3,]=NPV(p1-epsilon,p2);
> [,v6]=NPV(p1,p2-esilon);
> but it still complains.
>
> Many thanks in advance for your help.

What version of MATLAB do you have? In (I think) R2010a the ~ operator was introduced for outputs that would not be used later. Before that, standard practice was to use a dummy variable, as in:

[v1, dummy] = NPV(p1,p2);

to indicate that you weren't using the second output.

In any case, MATLAB should give you a warning in m-lint for not using the output later in your code. But it shouldn't be throwing errors or causing problems in your calculation.
From: Wayne King on
"Karst " <xiaoziliu(a)yahoo.com> wrote in message <i43m8h$21i$1(a)fred.mathworks.com>...
> NPV(p1,p2) is my sub-function which gives me two outputs[x,y]
> I have to call this function three times in my main function, see code below:
>
> [v1,v2]=NPV(p1,p2);
> [v3,v4]=NPV(p1-epsilon,p2);
> [v5,v6]=NPV(p1,p2-esilon);
>
> gradient1=v1-v3;
> gradient2=v2-v6;
>
> matlab codes complain that I did not use v2&v5 which is not needed in my main function calculation. Is there a way to avoid the complain?
>
> I tried to use
> [v3,]=NPV(p1-epsilon,p2);
> [,v6]=NPV(p1,p2-esilon);
> but it still complains.
>
> Many thanks in advance for your help.

Hi Karst, try
[v3,~]=NPV(p1-epsilon,p2);
[~,v6] = NPV(p1,p2-epsilon);

Wayne
From: Karst on

It works, many thanks. My version is 7.9.0


> Hi Karst, try
> [v3,~]=NPV(p1-epsilon,p2);
> [~,v6] = NPV(p1,p2-epsilon);
>
> Wayne
 | 
Pages: 1
Prev: Matlab fid problem
Next: FIR filter cutoff