how to access the outputs seperately?

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by