MATLAB: Relabel x-axis

loopsMATLAB

Hi
I am computing errors on a function and to ensure properly indexed data values have remapped my loop:
for n2=1:11
n=(n2-1)/10;
I am trying to to loop between 0 and 1 using 0.1 steps:
n= 0:0.1:1
Everything in the code works fine (I think!) At the end of my loop I have captured the data and attempt to plot.
I have used the simple command:
plot(error,'g')
This plots the error with the values n2 on the x-axis but I need them to show the values from n. The error does not need to change as this has been generated by the appropriate value (n) and not the index value (n2).
Does anyone know of a way to ensure the plot displays the correct value on the x-axis?
Best wishes
Joe

Best Answer

If ‘error’ is the same length as ‘n’, try this:
plot(n, error, 'g')