how to access the outputs seperately?

1 visualización (últimos 30 días)
sethu
sethu el 18 de Jun. de 2015
Comentada: sethu el 18 de Jun. de 2015
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 18 de Jun. de 2015
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 comentarios
Walter Roberson
Walter Roberson el 18 de Jun. de 2015
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 el 18 de Jun. de 2015
Thank you for your reply, it was just an instantaneous example provided by me for explaining the question clearly.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by