Problem in Matrix Indexing

1 visualizzazione (ultimi 30 giorni)
sita
sita il 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

Risposte (1)

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

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by