MATLAB: Could someone help me put this in a for loop

for loop

x1 = raw_data(:,1);
y1 = raw_data(:,2);
x2 = raw_data(:,3);
y2 = raw_data(:,4);
x3 = raw_data(:,5);
y3 = raw_data(:,6);
x4 = raw_data(:,7);
y4 = raw_data(:,8);
x5 = raw_data(:,9);
y5 = raw_data(:,10);
intX = [x1;x2;x3;x4;x5];
intY = [y1;y2;y3;y4;y5];
Thanks!

Best Answer

  • This is a frequently asked question:
    While it is possible, you generally do not want to do it.
    You can create intX by doing
    x = raw_data(:, 1:2:10);
    y = raw_data(:, 2:2:10);
    intX = x(:);
    intY = y(:);