Error when using ODE45
1 次查看(过去 30 天)
显示 更早的评论
Hello
I'm trying to write a code to solve a system of differential equations. One of the given conditions is F(0) = f(t). However when I try and implement that in the code I get an error. I believe that's because ode45 only wants variable inputs for the conditions. How do I get around this?
p_max = 50;
t = 2; % seconds
T = 0.2; % seconds
tau = 2; % seconds
c = 5; % m/s
L = 10; % meters
h = 5;
t = linspace(1,0.2,1000);
for i=1:1000
f(i) = (5/2)*(1-cos(2*pi*t(i)/T));
end
figure(1)
plot(t,f);
syms x y z
% t = x
% r = y
% p = z
F = @(t,x) [x(2); ((c^2)*(100/h^2)) - (1/tau)*x(2)];
[t,xa] = ode45(F,[0 20],[f 0]);
figure(2)
plot(t,xa(:,2))
title('y(t)')
xlabel('t'), ylabel('y')
Problem statement:
he series of the 2nd order ODE can be further reduced to a series of 1st order ODE, as shown in equation (40). The ODE system can be numerically solved with Matlab ODE45. Using the values of the parameters described in this paper, develop your matlab code to reproduce the results of Figures 2a and 2b in this paper based on the Maxwell material model.
Equation 40:
Initial Condition function:
Figures 2a and 2b:
0 个评论
采纳的回答
Star Strider
2018-3-7
What do actually want to do?
If ‘f’ is a forcing function, incorporate it with ‘t’ as an input to your differential equation, not as an initial condition.
4 个评论
更多回答(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!