Error in for loop: Index exceeds matrix dimensions.
Hi everyone! I need help with my code.I have a matrix (300×300) with some equal rows, and I need to eliminate the duplicate rows. I can’t solve the error. Can anyone help me??Thank you very much!
Below I copy the part of the code with the error and a simplified example.
clear all
matrix_f=[1 2 3; 1 2 3; 4 5 6; 7 8 9; 7 8 9; 10 11 12];
for k=1:length(matrix_f(:,1))
if matrix_f(k,1)==matrix_f(k+1,1)
matrix_f(k+1,:)=[];
end
endHi everyone! I need help with my code.I have a matrix (300×300) with some equal rows, and I need to eliminate the duplicate rows. I can’t solve the error. Can anyone help me??Thank you very much!
Below I copy the part of the code with the error and a simplified example.
clear all
matrix_f=[1 2 3; 1 2 3; 4 5 6; 7 8 9; 7 8 9; 10 11 12];
for k=1:length(matrix_f(:,1))
if matrix_f(k,1)==matrix_f(k+1,1)
matrix_f(k+1,:)=[];
end
end Hi everyone! I need help with my code.I have a matrix (300×300) with some equal rows, and I need to eliminate the duplicate rows. I can’t solve the error. Can anyone help me??Thank you very much!
Below I copy the part of the code with the error and a simplified example.
clear all
matrix_f=[1 2 3; 1 2 3; 4 5 6; 7 8 9; 7 8 9; 10 11 12];
for k=1:length(matrix_f(:,1))
if matrix_f(k,1)==matrix_f(k+1,1)
matrix_f(k+1,:)=[];
end
end for, for loop, matrix, index exceeds matrix dimensions. MATLAB Answers — New Questions