Error when using ODE45

1 回表示 (過去 30 日間)
Westin Messer
Westin Messer 2018 年 3 月 7 日
編集済み: Westin Messer 2018 年 3 月 7 日
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:

採用された回答

Star Strider
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.
See for example: ODE with Time-Dependent Terms (link).
  4 件のコメント
James Tursa
James Tursa 2018 年 3 月 7 日
Can you post the actual text of the problem statement?
Westin Messer
Westin Messer 2018 年 3 月 7 日
Yes, I have edited the question.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by