Info

This question is closed. Reopen it to edit or answer.

Error using - Matrix dimensions must agree. Error in odefcn line 4 dydt2 = diffdiffhe​avisidet*k​^2*t^2-6*k​*t*diffhea​visidet 12*heavisidet-6*k*t*y1 1

1 view (last 30 days)
Hi, cant solve non-linear equation system, please help.
function dydt = odefcn(t,y,k)
dydt = zeros(2,1);
dydt(1) = y(2);
dydt(2) = (diff(diff(heaviside(t)))*k^2*t^2-6*k*t*diff(heaviside(t))+12*(heaviside(t))-(6*k*t*y(1)+12*y))/k^2*t^2;
k = 1;
tspan = [0 5];
y0 = [0 0];
[t,y] = ode45(@(t,y) odefcn(t,y,k), tspan, y0);
plot(t,y(:,1),'-o',t,y(:,2),'-.')

Answers (0)

Community Treasure Hunt

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

Start Hunting!