Home > other >  Matlab for help
Matlab for help

Time:09-17

Exchange the first column of the matrix and the last column, please write why is wrong

CodePudding user response:

The function B=swap_ends (A)
N [M]=size (A);
B=zeros (M, N)
If N==1,
B=A;
Else,
B (:, 1: N)=A (:, [1] N 2: N - 1;
End,

CodePudding user response:

The function B=swap_ends (A)
N [M]=size (A);
B=zeros (M, N)
If N==1,
B=A;
Else,
B (:, 1: N)=A (:, [N, N - 1: - 1:2 1];
end,
  • Related