MATLAB: How to Solve differential equation differential equationsfsolvesolve Hi all I have equation like this dy/dt = a*y^2 + b*y + c where a, b and c are constant how can I solve this equation using matlab Best Answer I would use ode45 (unless your constants vary significantly in magnitude, then use ode15s).The code:a = 0.1; % Create Datab = 0.2; % Create Datac = 0.3; % Create Dataf = @(t,y) a.*y.^2 + b.*y + c; % Differential Equation Anonymous Functiontspan = [0 5]; % Time Spany0 = 0; % Initial Condition[t,y] = ode45(f, tspan, y0); % Numerically Integrate ‘f(y)’figure(1)plot(t,y)gridSee the documentation for ode45 for details. Related SolutionsMATLAB: I dont understand the vectors and element parts. Typo. Thisj*y*(1) <-- Uses the full vector y times the scalar 1should be thisj*y(1) <-- Uses only the y(1) element MATLAB: Runge kutta method for differantial equations systems y0 = [1, 2];[T, Y] = ode45(@OdeFcn, [0, 0.1], y0);plot(T, Y);function dy = OdeFcn(t,y)dy = [(10 * sin(314 * t) - 5 * y(1) - y(2)) / 0.01; ... 1000 * y(1)];end Related Question
Best Answer