필터 지우기
필터 지우기

How to create a vector of this output?

조회 수: 2 (최근 30일)
Kash Costello
Kash Costello 2018년 11월 29일
댓글: Star Strider 2018년 11월 29일
Hi!
Can anyone tell me how to do this in matlab? I've tried using 3 for loops but I am getting the wrong answer. My range is from -2 to 2.
Here is what I want to get:
... and so on and so forth.
Thanks a lot!

채택된 답변

Star Strider
Star Strider 2018년 11월 29일
Try this:
[X,Y,Z] = ndgrid(-2:2);
Out = [Z(:),Y(:),X(:)]
producing:
Out =
-2 -2 -2
-2 -2 -1
-2 -2 0
-2 -2 1
-2 -2 2
-2 -1 -2
-2 -1 -1
-2 -1 0
-2 -1 1
-2 -1 2
-2 0 -2
-2 0 -1
-2 0 0
-2 0 1
-2 0 2
etc.
  댓글 수: 2
Kash Costello
Kash Costello 2018년 11월 29일
THANK YOU <3
Star Strider
Star Strider 2018년 11월 29일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by