I need to update t and dx as shown below, but i keep getting the error: "unable to perform assignment because the left and right sides have a different number of elements."
I do understand that t(1) is 1 by 1 , while the new result 2 by 1.
What is the best way of going about this ?
This is the euler approach to analytical solution of ode.
h = 0.1;
t = 0:h:5;
y = zeros(size(t));
t(1) = -2;
n = numel(y);
y_dot = @(t,dx)[dx; -3*dx-7*t];
dx(i+1) = dx(i)+h*y_dot(t(i+1),dx(i));
dx(i+1) = dx(i) + h*y_dot(t(i+1),dx(i+1));