Function with matrices as output and input

1 Ansicht (letzte 30 Tage)
imro b
imro b am 21 Mär. 2016
Bearbeitet: Star Strider am 21 Mär. 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 :)

Antworten (1)

Star Strider
Star Strider am 21 Mär. 2016
Bearbeitet: Star Strider am 21 Mär. 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.

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by