Creating matrix from other matrix columns with loop?
2 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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
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)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!