Effacer les filtres
Effacer les filtres

how to convert matrix with arrays into vector

1 vue (au cours des 30 derniers jours)
Hossam Mosbah
Hossam Mosbah le 17 Juil 2017
Modifié(e) : James Tursa le 17 Juil 2017
I have this type of matrix
(2,1) 1.1348
(5,1) 0.49237
(1,2) 1.1348
(3,2) 0.65578
(4,2) 0.38773
(5,2) 0.25027
(2,3) 0.65578
(4,3) 0.33932
(2,4) 0.38773
(3,4) 0.33932
(5,4) 0.63002
(7,4) 0.11975
(9,4) 0.053962
So I am trying to get the vectors and use them in my program such as 1.1348, so how to convert the previous vector into regular vector like this
1.1348
0.49237
1.1348
0.65578
0.38773
0.25027
0.65578
0.33932
0.38773
0.33932
0.63002
0.11975
0.053962
  1 commentaire
Adam
Adam le 17 Juil 2017
I don't understand what your first type of matrix means. Are (2,1) etc the locations of points and the rest are 0s or is it a sparse matrix or some other meaning?

Connectez-vous pour commenter.

Réponse acceptée

James Tursa
James Tursa le 17 Juil 2017
Modifié(e) : James Tursa le 17 Juil 2017
Looks like you are working with a sparse matrix. To get the non-zero values into a column vector you could do this:
S = your sparse matrix
result = full(S(find(S)));
or another way
result = full(S(S~=0));

Plus de réponses (0)

Catégories

En savoir plus sur Sparse Matrices 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