How to select the first i columns of a matrix?

조회 수: 21 (최근 30일)
SSG_newbiecoder
SSG_newbiecoder 2018년 3월 20일
댓글: SSG_newbiecoder 2018년 3월 20일
Hello, I have a nxn matrix X. I need to select the first i columns alone of the matrix within a for loop. How can I do this? I'm not able to figure out the indexing for this. This is what I want
X =
-1.5145 -1.5475 -1.5556
-1.4254 -1.4856 -1.5085
-1.3363 -1.4237 -1.4614
first iteration
-1.5145
-1.4254
-1.3363
second iteration
-1.5145 -1.5475
-1.4254 -1.4856
-1.3363 -1.4237
  댓글 수: 2
M
M 2018년 3월 20일
편집: M 2018년 3월 20일
Maybe you should start by reading how to write for loop and read about indexing matrices in matlab.
Stephen23
Stephen23 2018년 3월 20일
A good place to learn basic (and important!) MATLAB concepts is by doing the introductory tutorials, which are highly recommended for all beginners:
These will teach you many important concepts that you need to know.

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

채택된 답변

Birdman
Birdman 2018년 3월 20일
for i=1:size(X,2)
X(:,1:i)
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix and Vector Construction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by