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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by