I am not getting a graph for my matlab program but I can run a program . I am attaching my file. can anyone help me with this?
Ältere Kommentare anzeigen
clear all;
global m k c w_f F0
m=2;
k=2000;
c=10;
w_f=12;
F0=5;
dt=0.005;
t=0:dt:2;
y0=[0 0.5 0];
%ODE function
function dy=testode3_force(t,y)
f1=F0*sin(2*pi*w_f*t);
dy=[f1/m-k*y(2)/m-c*y(1)/m;y(1)];
[tsol,ysol]=ode45('testode3_force',t,y0);
damping_ratio=c/(2*sqrt(k*m));
plot(t,ysol(:,2))
figure
plot(t,ysol(:,1))
end
Akzeptierte Antwort
Weitere Antworten (1)
Anjaneyulu Bairi
am 14 Jan. 2024
Hi,
I understand that you are not able to plot the graph with the above code. The function "testcode3_force" has plot code and it is not getting called anywhere in the code.Make sure you call it necessary arguments then it will resolve your query.
Code for function calling :
testcode3_force(t,y0);
%assuming your second input is y0
I hope it helps to resolve your query.
1 Kommentar
Puja
am 14 Jan. 2024
Kategorien
Mehr zu Ordinary Differential Equations 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!

