Creating matrix from other matrix columns with loop?

조회 수: 7 (최근 30일)
jack star
jack star 2016년 4월 23일
댓글: jack star 2016년 4월 23일
Hi all. I have data matrixes x(15x16) and y(15x16). And I want to create new matrix z(15x16) by taking some columns of x and y. For example, 3-4-5-10-12-14-16th columns will be taken from x and others from y. Is it possible with loop?

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 23일
편집: Azzi Abdelmalek 2016년 4월 23일
You don't need a loop
out=y
idx=[3 4 5 10 12 14 16]
out(:,idx)=x
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 23일
Yes, there is a mistake in the last line
y=zeros(15,16);
x=randn(15,16);
out=y
idx=[3 4 5 10 12 14 16]
out(:,idx)=x(:,idx)
jack star
jack star 2016년 4월 23일
Thanks.

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

추가 답변 (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