I am receiving an Error using plot
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ibraheem
am 24 Feb. 2025
Bearbeitet: Walter Roberson
am 24 Feb. 2025
I am getting this error when running my code
Error using plot
Data must be numeric, datetime, duration, categorical, or an array convertible to double.
Error in pendulun (line 27)
plot(t,y1, t,y2)
m1 = 49/1000;
m2 = 31/1000;
l1 = 0.5;
l2 = 0.5;
M = 1; % mlower/ m upper
l = 100/100; %lu/ l lower
A = (-9.8/1.0)*[(-(l + M*l +M)) M ; 1 -1]; % g/ l lower
w = eig(A);
[Aa,Bb] = eig(A);
omg = sqrt(w);
fre = omg/(2*pi);
nA = 1* A;
%nA = [2 -1; -1 2];
wn = eig(nA);
[S, V]= eig(nA);
syms x(t)
coslam = [(cos(sqrt(V(1,1))*t)) 0 ; 0 (cos(sqrt(V(2,2))*t))];
sinlam = [(sin(sqrt(V(1,1))*t)) 0 ; 0 (sin(sqrt(V(2,2))*t))];
Solu = (S*coslam*(inv(S))*[1/100 ;1/100]) + (S* sinlam* (sqrtm(inv(V)))*(inv(S))*[0;0]);
hold on
t = linspace (0,10,1000000);
y1 = Solu(1);
y2 = Solu(2);
plot(t,y1, t,y2)
title (['Plot of y_{1}(t) and y_{2}(t) of the pendulum' ...
' l2 = 1m, M =0.6327, L= 1'])
grid
xlabel ('Time (s)')
ylabel('Distance(m)')
legend('y1(t)','y2(t)')
0 Kommentare
Akzeptierte Antwort
Star Strider
am 24 Feb. 2025
m1 = 49/1000;
m2 = 31/1000;
l1 = 0.5;
l2 = 0.5;
M = 1; % mlower/ m upper
l = 100/100; %lu/ l lower
A = (-9.8/1.0)*[(-(l + M*l +M)) M ; 1 -1]; % g/ l lower
w = eig(A);
[Aa,Bb] = eig(A);
omg = sqrt(w);
fre = omg/(2*pi);
nA = 1* A;
%nA = [2 -1; -1 2];
wn = eig(nA);
[S, V]= eig(nA);
syms x(t)
coslam = [(cos(sqrt(V(1,1))*t)) 0 ; 0 (cos(sqrt(V(2,2))*t))];
sinlam = [(sin(sqrt(V(1,1))*t)) 0 ; 0 (sin(sqrt(V(2,2))*t))];
Solu = (S*coslam*(inv(S))*[1/100 ;1/100]) + (S* sinlam* (sqrtm(inv(V)))*(inv(S))*[0;0]);
Solufcn = matlabFunction(Solu)
hold on
t = linspace (0,10,1000000);
Solv = Solufcn(t)
y1 = Solv(1,:);
y2 = Solv(2,:);
plot(t,y1, t,y2)
title (['Plot of y_{1}(t) and y_{2}(t) of the pendulum' ...
' l2 = 1m, M =0.6327, L= 1'])
grid
xlabel ('Time (s)')
ylabel('Distance(m)')
legend('y1(t)','y2(t)')
.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
