Function with matrices as output and input

1 vue (au cours des 30 derniers jours)
imro b
imro b le 21 Mar 2016
Modifié(e) : Star Strider le 21 Mar 2016
Hello, I am asking for help with plotting 3 outputs of function as Ys with input as X.
My algorithm for the function is
function [u,v,w]= g5(t)
A=[6 9 15
-5 -10 -21
2 5 11];
S=[1;2;3];
for f=t
U=expm(A*f)*S;
end
U
I want input to be I=0:0.01:1.
Thanks :)

Réponses (1)

Star Strider
Star Strider le 21 Mar 2016
Modifié(e) : Star Strider le 21 Mar 2016
This would be my approach:
function U = g5(t)
A=[6 9 15
-5 -10 -21
2 5 11];
S=[1;2;3];
for f=1:length(t);
ti = t(f);
U(:,f)=expm(A*ti)*S;
end
end
Then in your calling script:
I=0:0.01:1;
U = g5(I);
figure(1)
plot(I, U)
grid
I didn’t include ‘v’ and ‘w’ in the output arguments because you didn’t define them in your code. Add them when you do.

Catégories

En savoir plus sur Mathematics 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!

Translated by