What does A(2:4) = [ ] do if A is a 3x3 matrix?
3 views (last 30 days)
James Tursa on 17 May 2022
Edited: James Tursa on 17 May 2022
This is linear indexing. Even though the variable is a 2D matrix, MATLAB allows you to index into it using only one index. The linear indexes are simply numbered 1-numel(variable) (1-9 in your case) as they are ordered in memory. MATLAB will delete the 2nd, 3rd, and 4th element of the variable and return the result as a 1D vector. Since MATLAB stores variables in column order, this means the 32, -1, and 17 values are deleted.