how to access the outputs seperately?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponse acceptée
Walter Roberson
le 18 Juin 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 commentaires
Walter Roberson
le 18 Juin 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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!