how to access the outputs seperately?

1 回表示 (過去 30 日間)
sethu
sethu 2015 年 6 月 18 日
コメント済み: sethu 2015 年 6 月 18 日
suppose i have a function f(x) =@(t) sim(net,t'). It has 2 outputs how can i seperate them? example: f(1) = [1,2], f(2) =[3,4], f(3) = [5,6] .... then how can i call only 1st outputs of the above results (i.e, {1,3,5 etc}) i hope that i was able to explain my problem, looking forward for an answer.

採用された回答

Walter Roberson
Walter Roberson 2015 年 6 月 18 日
Assign them to a variable and index them.
Or if you really want to do it in an expression, define an anonymous function such as
Col1 = @(V) V(:,1);
and then you can code things like
f = @(t) Col1(sim(net,t'));
  3 件のコメント
Walter Roberson
Walter Roberson 2015 年 6 月 18 日
Yes if you used @(v) v(1,:) that would get the first row, and I would suggest you name it appropriately such as row1 instead of col1 (column 1).
Be aware that you asked for the routine to work on [1 2]. That is a row vector, so the first row of it would be identical to the vector. If you want the 1 part, that is column 1 of the vector, not row 1 of the vector.
sethu
sethu 2015 年 6 月 18 日
Thank you for your reply, it was just an instantaneous example provided by me for explaining the question clearly.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by