MATLAB: How to get a vector to put all the elements in one vector

elements in a vectoreuler's method

Hello all,
I've been trying for a while to get the V vector in the euler's method for solving and IVP code that I made below to give out the 6 elements in one vector not separately like it is doing. I have tried moving it around and adding or removing the ; at the end and that either takes it away completely or just gives me the last entry. I would greatly appreciate any help.
function m = eulersmethod(n,t0,t1,w0,f,q)
h=(t1-t0)/n;
t(1)=t0;
w(1)=w0;
v=[];
V=[];
for i=1:n
t(i+1)=t(i)+h;
w(i+1)=w(i)+h*f((t(i)),(w(i)));
end
for i=1:n+1
y=q(t0+(i-1)*h);
if i<=n+1
i=i+h;
end
V=[y]
end
v=[t',w']
end
output code
fheulersmethod(5,1,2,0,fhf,fhq)
V =
0
V =
0.866642535759602
V =
2.620359551235833
V =
5.720961525596339
V =
10.793624660490639
V =
18.683097081886419
v =
1.000000000000000 0
1.200000000000000 0.543656365691809
1.400000000000000 1.681068828003871
1.600000000000000 3.751012594436661
1.800000000000000 7.224718344336123
2.000000000000000 12.750382866683738

Best Answer

for i=1:n+1
y(i) = q(t0+(i-1)*h);
end
V = y;
Related Question