Problem in Matrix Indexing

1 次查看(过去 30 天)
sita
sita 2012-11-22
Hi, below code i am trying to read matrix elements from an array of elements. i should get 5x3 matrix like
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
but i am gettting like below
1 2 3
1 2 3
1 2 3
1 2 3
3 3 3
i understand there is some problem with indexing.
Please help me in getting this.
Thanks,
Sita
n=5; v=3; k=[1 2 3];
for i=1:n
x=0;
for j=1:1:v
x=x+1;
f(:,j)= k(x);
end
f(i,:)=k(x)
f(:,(1:3))
end

回答(1 个)

Walter Roberson
Walter Roberson 2012-11-22
Remove the f(i,:)=k(x)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by