Solve a system of linear ODEs, and plot them
Ältere Kommentare anzeigen
I have a system of Linear ODEs. and I tried the following code, based on an example from matlab.com
clear all
clc
format short e
syms x(t) y(t) v(t) q(t) u(t) s(t) z(t)
A=[-108.15802678, -96035700000, 99.9039643, 100, -9603.57, -96.0357, 100;
-0.00104128, -96035700000, 0, 0, 0, 0, 0;
102.8581245, 0, -100.0960357, 100, 9603.57, 0, 0;
0.0988755, 0, 0.0960357, -100, 0, 0, 0;
-102.957, 0, 100, 0, -9603.57, 0, 0;
-5.10111, 0, 0, 0, 0, -96.0357, 100;
5.10111, 0, 0, 0, 0, 96.0357, -100];
B=[ 0.001; 0.001; 0; 0; 0; 0; 0];
tspan = [0, 0.5, 10];
R=[x; y; v; q; u; s; z];
odes= diff(R) == A*R + B
C = R(0) == [10^-7, 10^-7, 0, 1, 0, 0.1, 0];
[xSol(t), ySol(t), vSol(t), qSol(t), uSol(t), sSol(t), zSol(t)] = dsolve(odes,C);
xSol(t) = simplify(xSol(t))
ySol(t) = simplify(ySol(t))
vSol(t) = simplify(vSol(t))
qSol(t) = simplify(qSol(t))
uSol(t) = simplify(uSol(t))
sSol(t) = simplify(sSol(t))
zSol(t) = simplify(zSol(t))
clf
fplot(xSol)
hold on
fplot(ySol)
hold on
fplot(vSol)
hold on
fplot(qSol)
hold on
fplot(uSol)
hold on
fplot(sSol)
hold on
fplot(zSol)
grid on
legend('xSol','ySol','vSol','qSol','uSol','sSol','zSol','Location','best')
Although I get the results, I do not get any plots. It just shows a plot with no graph/lines/points on it. Any opinion on how to solve it?
I really appreciate any help,
1 Kommentar
M
am 20 Sep. 2021
Bearbeitet: Walter Roberson
am 20 Sep. 2021
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Equation Solving finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!