ode45 for third order differential
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to solve a third order differential equation by representing it as a set of first order diff equations. The constants are user input arguments.
A=str2double(get(handles.Avalue, 'string'));
B=str2double(get(handles.Bvalue, 'string'));
C=str2double(get(handles.Cvalue, 'string'));
E=str2double(get(handles.Evalue, 'string'));
F=str2double(get(handles.Fvalue, 'string'));
t=str2double(get(handles.tvalue, 'string'));
xinitial=0;
where t is the final value on the x axis
[T,X] = ode45(@funsys, [0 t], [0 0 0 0]);
plot(T, X(:,1), 'Parent', handles.axes1)
plot(T, X(:,2), 'Parent', handles.axes2)
plot(T, X(:,3), 'Parent', handles.axes3)
plot3(X(:,1),X(:,2),X(:,3), 'Parent', handles.axes4)
I am using the following function stored in a separate m file
function diff_f=funsys(t,x,A,B,C,E,F)
diff_f=zeros(4,1);
diff_f(1)=x(2);
diff_f(2)=x(3);
diff_f(3)=x(4);
diff_f(4)=(F*exp(-0.1*t)*cos(t)+B*x(4)-C*t*x(3)+E*x(2))/A;
end
Whenever I run it I receive an error message:
Not enough input arguments.
Error in funsys (line 7)
diff_f(4)=(F*exp(-0.1*t)*cos(t)+B*x(4)-C*t*x(3)+E*x(2))/A;
I tried using syms x to see if x is the problem, otherwise all other arguments are present.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!