how do i use a for loop to change the matrix
B= [1 0 0;
0 1 0;
0 0 1]
to
A= [0 0 1;
0 1 0;
1 0 0]
for any size matrix

댓글 수: 2

James Tursa
James Tursa 2017년 1월 26일
편집: James Tursa 2017년 1월 26일
What are the rules for changing any size matrix? Exchange the (1,1) element with the (1,end) position? Flip the order of all of the elements of the 1st row? Or what? I can think of several rules that would fit your small example. And why do you need to use a for loop for this? Is that a homework requirement?
Morgan Kaye
Morgan Kaye 2017년 1월 26일
Yes this is the question: "Assume you are already given a matrix B with n rows in MATLAB. Using for loop(s), write the MATLAB code that returns a matrix C that consists of the rows of B in the opposite order." and then it gives the previously shown matrixes and says it must work for any size. im having trouble using a for loop to do this

댓글을 달려면 로그인하십시오.

답변 (1개)

Guillaume
Guillaume 2017년 1월 26일

0 개 추천

C = fliplr(B);
for i = 1:10000
%twiddle thumbs
end
I suggest you make an attempt at solving this extremely easy problem and then come back with a very specific question if you encounter a problem.

카테고리

도움말 센터 및 File Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

질문:

2017년 1월 26일

답변:

2017년 1월 26일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by