MATLAB: Plot in Matlab with delay of 2

graphplottingprogramming

Trying to plot a return map with U_n-2 on x axis and U on y axis. Here is my current code:
U=load('U.txt'); %U has 1 column with 280000 values
L = length(U);
N = 1:1:L;
figure(1)
plot(U(0:L-2),U(2:L))
I keep getting this error:
Subscript indices must either be real positive integers or logicals.
Error in U plot(U(0:L-2),U(2:L))
I'm pretty new with this program, and I'm not sure how to fix this.

Best Answer

Arrays start at 1 in MATLAB, so 0 is not a valid subscript.
Related Question