MATLAB: Solution of swing equation which is a 2nd order differential equation. ode45 This is my system. I Need to solve it by using ode45. P, M and D are constants. Thanks for help in advance !!! Best Answer It can be solved using ode45 like this.create 1 function file with the following instructions. function dydt = swingeqn(~,del,pmax,M,D) dydt=zeros(2,1); dydt(1)=del(2); dydt(2)=-(pmax/M)*sin(del(1))-D*del(2);Now call it from script file clc clear all pmax=-5; M=1; D=0.1; tspan=[0,10]; del0=[0 1];[t,del]= ode45(@(t,del) swingeqn(t,del,pmax,M,D),tspan,del0); % Calling the function swingeqnplot(t,del(:,2));xlabel('Time in Sec');ylabel('Delta, Omega'); Related SolutionsMATLAB: How to plot ode 45 for different values of a constant after specific time function main T = 1:1:3100; del = 0.0; [t1,y1] = ode45(@(t,y)f_1(t,y,del),T,C); T = 3100:1:3500; del = 1.0; C = y1(end,:); [t2,y2] = ode45(@(t,y)f_1(t,y,del),T,C); t = [t1;t2]; y = [y1;y2]; plot(t,y)endfunction dy = f_1(t,y,del) ...end MATLAB: Error using odearguments (line 93) PHASE_1 must return a column vector. You have the indices reversed. Try this: function dydt = Phase_1(t, y)dydt(1,1) = y(3);dydt(2,1) = y(4);dydt(3,1) = 2*t;dydt(4,1) = 1.5*t;dydt(5,1) = t^(1/9);dydt(6,1) = t^(1/6);end Related QuestionMatlab ode45 not enough input arguments
Best Answer