multiple 1x1 cell array to struct
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Vilém Frynta
am 16 Mär. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!