I am trying to use a fixed step solver, such as ODE4 to calculate a value after a fixed time step, however, I am getting stuck on a very basic point. I have to pass F to the ode solver however, obviously because it is an ode, I have the variable that I need to find in F so it is giving me " variable undefined" error. This error is obvious to me but is there a way around it?
I am using the following function from mathworks – ode4 . Please find the code in the functions tab.
And my function calling statement is –
t = linspace(1,10)vp(1) = 5 %some constant that changes in the loop below
for i = 1: length(t) v = ode4((v - vf), t(i), 1, t(i+1),vp(1)); vp(1) = 45; % some updated value ( I've chosen a random number for the time being)
end%error displayed
% -->> Undefined function or variable 'v'.
Best Answer