From: MZ AM on
Hi,

Is there any way that the ith output argument of a function can be accessed without getting all the output arguments?

for example I have a function:

function [out_1,out_2......,out_10]=myfunction(in_1,in_2......,in_6)
..
..
..

then I need to call to get only out_5.
I am in need of doing so because I am using a nonlinear constraint function (G<0) with the optimization function "fmincon" where G only takes one input variable (e.g. G(x) ). My G(x) is out_5 in the above function.

Thanks.
From: Matt J on
"MZ AM" <mazamin(a)yahoo.com> wrote in message <hrsjro$8or$1(a)fred.mathworks.com>...
> Hi,
>
> Is there any way that the ith output argument of a function can be accessed without getting all the output arguments?
>
> for example I have a function:
>
> function [out_1,out_2......,out_10]=myfunction(in_1,in_2......,in_6)
> .
> .
> .
>
> then I need to call to get only out_5.
========================

With a sufficiently recent version of MATLAB, you can call the function as follows

[~,~,~,~,out_5]=myfunction(in_1,in_2......,in_6)
From: dpb on
MZ AM wrote:
> Hi,
>
> Is there any way that the ith output argument of a function can be
> accessed without getting all the output arguments?
>
> for example I have a function:
>
> function [out_1,out_2......,out_10]=myfunction(in_1,in_2......,in_6)
> .
> .
> .
>
> then I need to call to get only out_5.

Wrap myfunction in another function that simply passes on the
required/wanted output.


--
From: Walter Roberson on
MZ AM wrote:

> Is there any way that the ith output argument of a function can be
> accessed without getting all the output arguments?

No.


> for example I have a function:
>
> function [out_1,out_2......,out_10]=myfunction(in_1,in_2......,in_6)
> ..
> ..
> ..
>
> then I need to call to get only out_5.
> I am in need of doing so because I am using a nonlinear constraint
> function (G<0) with the optimization function "fmincon" where G only
> takes one input variable (e.g. G(x) ). My G(x) is out_5 in the above
> function.

function out_5 = G5(in_1,in_2,...,in_6)
[out_1, out_2,...,out_10] = myfunction(in_1,in_2,...in_6);
end

And then use G5 as your function instead of G.

Unfortunately, there is no way to do this with an anonymous function or
with any Matlab provided operator: the way Matlab is designed, there has
to be a real assignment statement in order to extract a particular
output from a call.
From: us on
"MZ AM" <mazamin(a)yahoo.com> wrote in message <hrsjro$8or$1(a)fred.mathworks.com>...
> Hi,
>
> Is there any way that the ith output argument of a function can be accessed without getting all the output arguments?
>
> for example I have a function:
>
> function [out_1,out_2......,out_10]=myfunction(in_1,in_2......,in_6)
> .
> .
> .
>
> then I need to call to get only out_5.
> I am in need of doing so because I am using a nonlinear constraint function (G<0) with the optimization function "fmincon" where G only takes one input variable (e.g. G(x) ). My G(x) is out_5 in the above function.
>
> Thanks.

one of the other side of the solutions

[ix,ix,ix,iy,iy]=yourfcn(a,b,c);
% with
% IX = third output arg
% IY = fifth output arg

us
 | 
Pages: 1
Prev: VB6.0 interface with Matlab
Next: vector division