Cell array data to double conversion
이전 댓글 표시
Hi all,
I have a cell array that I want to transform to a double array. Then I would like to fill in the double array with data from cell arrays. To solve this problem I have tried two things:
- I have tried cell2mat, which gave a result that I couldent interpret and didnt work.
- I tried str2double, this does not give an error, but it writes only NaN values in the double array.
The names of the variables are
- Comp_all: cell array
- dat: translate cell to double
- dat2013: double array which I would like to fill in
How can I transfer both numeric and non-numeric data from cel arrays to double arrays?
The code is used to do this looks like:
dat = str2double(Com_all);
dat2013 = zeros(length(dat),5);
dat2013(1:end,1) = dat(1:end,1);
댓글 수: 7
the cyclist
2019년 11월 7일
Can you upload the data (or a small subset) in a *.mat file, using the paper clip icon?
Wouter Wizard
2019년 11월 7일
"But the first column of my cell array has names of countries."
Use a table. A table is probably the best way to store data with a header.
"I have added the data here"
You uploaded some code, but no data.
Wouter Wizard
2019년 11월 7일
Wouter Wizard
2019년 11월 7일
Guillaume
2019년 11월 8일
Stephen's advice: "Use a table. A table is probably the best way to [work with your type of data"
Note that I already gave you that advice (and plenty more...) several days ago in a question that you then deleted (so I completely wasted my time helping you).
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!