How do I pas one scalar from a function that outputs an array?

I have a function that does this:
function [A, B, C] = func(x)
A = x^2;
B = x^3;
C = x^4;
end
I want to pass it in another function like this:
ans = func2(@func,xx)
But I only want to pass B; not A or C. How do I go about doing this? Thanks

回答 (1 件)

dpb
dpb 2015 年 10 月 11 日

0 投票

Is no Matlab syntax to do that directly; use an intermediate temporary variable to hold the result.
If must have a function handle the best I can think of is would have to have a wrapper function around the original that returns only the desired output.

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

製品

質問済み:

2015 年 10 月 11 日

回答済み:

dpb
2015 年 10 月 11 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by