Effacer les filtres
Effacer les filtres

how to convert matrix A 1 x 200 into 100 x2

1 vue (au cours des 30 derniers jours)
Laura
Laura le 10 Juin 2013
I have a matrix A=( x1 y1 x2 y2....)
Now I want all the value of x in one column and y in one column.
I had been tried
for i= 1: N
x= A(1,2*i-1);
y= A(1,2*i);
end
Please helps. Thanks

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 10 Juin 2013
Modifié(e) : Azzi Abdelmalek le 10 Juin 2013
Edit
A=[1 2 3 4 5 6]
out=reshape(A,2,[])'
%or
out=[A(1:2:end)' A(2:2:end)']

Plus de réponses (1)

Jan
Jan le 10 Juin 2013
Modifié(e) : Jan le 10 Juin 2013
You almost got it. Simply move the loop into the indexing:
x = A(1, 1:2:2*N-1)';
y = A(1, 2:2:2*N)';

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by