简体   繁体   中英

MATLAB nested handle returning multiple outputs

I have a function handle that returns 3 values.

@f(x,y) = basis_handle(x,y);

[z, dx, dy] = f(0.1,0.1) %returns 3 vectors

what I'd like to do now is create a function handle that performs a dot product of each of those 3 vectors with another vector. Something like:

@f_2(x,y) c'*f(x,y) %c is a known vector, same size as ones returned by @f(x,y)

As it is, this handle returns only 1 value, even if I try to ask for more, ie this produces an error:

[z, dx, dy] = f_2(0.1,0.1)

Is there any way to create a function handle that returns all 3 values as requested?

I was wondering whether this helps (actually it is equivalent to pass the three outputs to different variables which can be defined in your f_2):

function varagout = f_1(x,y) 
varagout=[x + 1 y-x y/x];

and,

function varagout = f_2(x,y) 
C=[1 2 3];
varagout=C.*f_1(x,y);


>> f_1(0.1,0.1)
ans = 1.1000         0    1.0000
>> f_2(0.1,0.1)
ans = 1.1000         0    3.0000

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM