multiple 1x1 cell array to struct
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Vilém Frynta
2023년 3월 16일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!