Problem in Matrix Indexing

2 views (last 30 days)
sita
sita on 22 Nov 2012
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

Answers (1)

Walter Roberson
Walter Roberson on 22 Nov 2012
Remove the f(i,:)=k(x)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!