I need help with create a function
1 view (last 30 days)
Show older comments
Well I have problems to create my function, that resolves a 2 simultaneous equations. ODE by Euler's Step. here is my script:
function y = funcion(u,v)
y(1)= u*(v-2)
y(2)= v*(1-u)
end
function y1= metodoeuler(h,u0,v0)
y1 = u0 + h*funcion(u0,v0)
%initial time
v0 =0;
%final time
ufinal = 10;
%number of steps
nsteps = 80;
y =[2;2];
%step size
h= (ufinal - v0)/ nsteps;
%set the variable t.
v = v0;
%go through the steps
for j=1 : nsteps
u = metodoeuler(h,u,v);
v = v + h;
%saved output for u(t) only, i.e. the first component of y.
tout(j) = t;
d(j) = y(1);
end
%draw a figure for the solution u
plot(tout,u,'-')
The warning its that u its my incognite ... i cant undestand
1 Comment
Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!