I am a newbie to mathlab. I try follow what in the example in the notes. But error occurs. I do not know why it is like that.
Can anyone please help me see this code got any problem?
x'' − 3x' + 2x = te^t, x(0) = 0, x'(0) = −2.
function xdot = myfunction(t,x)
xdot = zeros (2,1);
xdot(1) = x(2);
xdot(2) = 3*x(2) - 2*x(1)+t.*exp(t); %only need to change this line
This is exactly the same from the notes. when i try run it at mathlab window, error occurs. it can't recognised xdot(1) = x(2)
Can anyone explain to me? I have never try create function before.
Please show the calling code for your function. It should be something like:
Originally Posted by elliotyang