how can I write a code segment that flips an N*M array up to down *Do not use loops or flip function

댓글 수: 2

James Tursa
James Tursa 2020년 12월 26일
What have you done so far? What specific problems are you having with your code?
Stephen23
Stephen23 2020년 12월 27일

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

 채택된 답변

Image Analyst
Image Analyst 2020년 12월 25일

4 개 추천

What did your course tell you about indexing? Like
indexes = startingValue : stepValue : endingValue;
If you still need help, reply only after reading the link below:

댓글 수: 5

omar khasawneh
omar khasawneh 2020년 12월 25일
sorry , is there any mistake with my question ? !
Image Analyst
Image Analyst 2020년 12월 25일
Do you want us to do your homework for you so that you can turn in our code to your class while telling your professor that you wrote the code yourself? Please explain what you want us to do for you and what you will do with our answer.
omar khasawneh
omar khasawneh 2020년 12월 26일
Listen , I never allow you to accuse me of lying to my professor, if you also lie, that's your problem.
I asked because I really need help, I don't need to manipulate as you pretend, and I didn't ask you to solve the question
Image Analyst
Image Analyst 2020년 12월 26일
Read my comment again - there is no accusation. Just a question as to explain how we can help you with this question that can be solved in one line of code. Since it's only one line of code, it's hard to help you without doing the whole thing for you. That's why I gave the hint I did. If I give any more than that, then it's completely done and there is nothing more for you to do. At least this way, I think you can change variable names and be able to say you did it yourself.
Jan
Jan 2020년 12월 27일
@omar khasawneh: There is no accusation. Image Analyst gave you a useful hint.

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

추가 답변 (1개)

omar khasawneh
omar khasawneh 2020년 12월 26일

0 개 추천

okay , I got it ...
I solved like this A = [1 2 3 ; 4 5 6; 7 8 9];
A = A' % transpos
A = rot180(A) %rotation

댓글 수: 1

OK, that works as long as you have written a special rot180() function. I'm not seeing it in base MATLAB. If I instead use imrotate() to do that part:
A = [1 2 3 ; 4 5 6; 7 8 9];
A = A' % transpos
% A = rot180(A2) %rotation
A = imrotate(A, 180)
I get
A =
1 4 7
2 5 8
3 6 9
A =
9 6 3
8 5 2
7 4 1
Which is not flipped up to down. It also flips left to right.
The solution most MATLABers would use is a single line of code using the hint I gave. So here is a little bit more:
A = A(startingValue : stepValue : endingValue, :);
That's it. One single line of code. See if you can supply the values.

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

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

릴리스

R2015a

질문:

2020년 12월 25일

댓글:

Jan
2020년 12월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by