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