How to use ODE45 to solve 2nd order differential equation with random variables in it?
4 次查看(过去 30 天)
显示 更早的评论
In Quarter car model equations, (see above attached file for skematic model)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/643500/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/643505/image.png)
where
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/643510/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/643515/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/643520/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/643525/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/643530/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/643535/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/643540/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/643545/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/643550/image.png)
how could i apply this random variables to the equations by using ode45 ?
I have done for one sample, any hint to simulate for 100 samples.
dt = 0.01;
tf = 30;
tspan = dt:dt:tf;
y0 = [0;100;0;10];
[t,y] = ode45('eqsystem',tspan,y0);
plot(y(:,1))
grid
xlabel('X-Displacement')
ylabel('y-Displacement')
title('X vs Y Displacement')
hold on;
function dydt = eqsystem(t,y)
ks = 1000; % N/m^3 - Gaussian
ku = 1000; % N/m - Gaussian
ms = 10; % kg - Gaussian
mu = 20; % kg - Gaussian
c = 300; % Ns/m - Gaussian
A = 0.10; % m -
omega = 2*pi; % rad/s -
dydt = zeros(4,1);
dydt(1,:) = y(2);
dydt(2,:) = ((-ks/ms)* (y(1)-y(3))^3 - (c/ms)*(y(2)-y(4)));
dydt(3,:) = y(4);
dydt(4,:) = ((ks/mu)*(y(1)-y(3))^3 + (y(2)-y(4)) + ku*(A*sin(omega*t) - y(3)));
end
2 个评论
采纳的回答
Jan
2021-6-6
dt = 0.01;
tf = 30;
tspan = dt:dt:tf;
y0 = [0;100;0;10];
for k = 1:100
ms = 10 + randn;
mu = 20 + randn * 2;
...
fcn = @(t, y) eqsystem(t, y, ms, mu, ...)
[t, y] = ode45('eqsystem',tspan,y0);
end
function dydt = eqsystem(t, y, ms, mu, ...)
dydt = zeros(4,1);
dydt(1) = y(2);
dydt(2) = (-ks / ms) * (y(1) - y(3))^3 - (c/ms) * (y(2) - y(4));
dydt(3) = y(4);
dydt(4) = (ks / mu) * (y(1) - y(3))^3 + (y(2) - y(4)) + ...
ku * (A * sin(omega * t) - y(3));
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!