Cody Problem 19. Swap the first and last columns
이전 댓글 표시
here is my solution:
function B = swap_ends(A)
C = A(:,end);
D = A(:,1);
A(:,end) = [];
A(:,1) = [];
B = [C A D];
end
For A=1, I got an error and idn how should I solve that.
I would appreciate any help! Thanks in advance :)
채택된 답변
추가 답변 (1개)
Abhinav
2023년 4월 26일
0 개 추천
function B = swap_ends(A)
B = A;
k = B(:,1);
B(:,1) = B(:,end);
B(:,end) = k;
end
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!