Question

help me with this. Im done with task 1 and on the way to do task 2. but I don't know how to do it. I attach 2 file function of rksys and ode45 ( the first is rksys and second is ode 45) . thank for your help

Consider the spring-mass damper that can be used to model many dynamic systems -- ----- ------- m Applying Newtons Second Lam function (RR = rk4sys (dydt, tspan, yo, h) 3 rk4sys: fourth-order Runge-Kutta for a system of ODES l - 1k4sys (dydt, tspan,vmid = yli,:) + k1.*hh./2; k2 = dydt (tethh/2ymid); vmid = xli,:) + k2*hh/2; 13 = dydt (te+hh/2, ymid); vend = yli, :) + k3

0 0
Add a comment Improve this question Transcribed image text
Answer #1

%i have created the script as well as the function. You need to change parameters as needed. If any error is there, please tell in comments, I will fix it

y0=[0;0];
tstart=0;
tend=1;%edit it accordingly
h=.1;%change as needed
tspan=[tstart,tend];
[t_23s,y_23s]=ode23s(@forcedvibration,tspan,y0);%calling ode23s
[t_45,y_45]=ode45(@forcedvibration,tspan,y0);%calling ode45
[tp,yp]=rk4sys(@forcedvibration,tspan,y0,h);%calling rk4sys
plot(t_23s,y_23s(:,1),t_45,y_45(:,1),tp,yp(:,1))
xlabel('t')
ylabel('x')
title('displacement')
legend('ode 23s','ode45','rk4sys')
figure
plot(t_23s,y_23s(:,2),t_45,y_45(:,2),tp,yp(:,2))
xlabel('t')
legend('ode 23s','ode45','rk4sys')
ylabel('x''')
title('slope')

%the required function
function y = forcedvibration(t,x)
A=1000;
B=100;
k=50;
w=pi/2;
m=10;
f=A*exp(-B*t).*cos(w.*t);
y=[x(2);(f-k*x(1)-B*x(2))/m];
end

Add a comment
Know the answer?
Add Answer to:
help me with this. Im done with task 1 and on the way to do task...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT