multiple 1x1 cell array to struct
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I am importing a text file into matlab, converting the text to a table and importing each row with numbers as a cell array. I would like to convert each line into individual numbers then insert into a struct. Is there a good approach to this? Example below
line 87: '0.200 0.486 0.000 0.486 0.001 0.100 9.670 -40.808 10.017 3.190 7.886'
=> convert each text number (to an actual number)....
x(1,1) = 0.200,
x(1,2) = 0.486, etc... all while importing into a struct
0 comentarios
Respuestas (1)
Vilém Frynta
el 16 de Mzo. de 2023
After your loop ends, you can simply assign all the numbers into a column of a struct. It would be much faster than importing in a loop.
I hope this is what you needed. Hope it helped.
% Vector from 1 to 100
x = 1:1:100
% Import into struct (as a 1 column)
struct.Nums = x
0 comentarios
Ver también
Categorías
Más información sobre Data Type Conversion en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!