Im doing an assignment where my script should repeats forward euler for different step sizes h between 0.1V/g and 0.001V/g, doubling the number of steps taken each time,and making sure the final time is exactly 3V/g.
function [z,v,studentid] = particle(m,g,k,p,V,h,N)
Above is the function I use for forward euler, and below is the code in another script where im trying to change the step size.
for x=[2 6]
I feel like ive done it a completely harder way than I need to and wondered if I could simplify it somehow. The assignment also asks me to plot two clearly labelled graphs (using the subplot command), of the magnitude of the error versus h, on log-log axes.
The error for each line is just z(x)-z as it says below, but when i try to run that it says 'Index exceeds the number of array elements (1)'
If someone could please help me that would be so so amazing, I have hit a wall with this.