String array to matrix

4 vues (au cours des 30 derniers jours)
Ádám Herpai
Ádám Herpai le 22 Mai 2022
Commenté : Ádám Herpai le 22 Mai 2022
Hi,
I have data as a 12487x1 string which row's cointains data separated by tabulators. I want to make this into a matrix, where the tabulators separate the columns in the matrix.
Thnaks in advance

Réponse acceptée

Matt J
Matt J le 22 Mai 2022
Modifié(e) : Matt J le 22 Mai 2022
Here's an example with comma separators instead of tabs, but it would work the same way.
a=["1,2";"3,4"]
a = 2×1 string array
"1,2" "3,4"
c=arrayfun(@(z)strsplit(z,','),a,'uni',0);
out=str2double(vertcat(c{:}))
out = 2×2
1 2 3 4
  1 commentaire
Ádám Herpai
Ádám Herpai le 22 Mai 2022
Thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Cell Arrays dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by