MATLAB: Struct contents reference from a non-struct array object. for importing file

struct contents reference from a non-struct array object.

lab4_plot_data.txt is 2×100 double
X=importdata('lab4_plot_data.txt')
x=X.data(1,:); y=X.data(2,:);
error message is "Struct contents reference from a non-struct array object. Error in lab4t2 (line 7) x=X.data(1,:); "

Best Answer

You forgot to attach lab4_plot_data.txt, but my guess is that X is just a regular 2-d array of numbers, so you'd do
x = X(1, :); % x is row 1 of the data
y = X(2, :); % y is row 2 of the data
Try that and attach lab4_plot_data.txt if it doesn't work.
Related Question