My data is with size of 2050x1 and its class label as 'cell', how do convert it into double so that i can plot the graph? thanks for the help in advance

 채택된 답변

Geoff Hayes
Geoff Hayes 2017년 7월 19일

4 개 추천

Gil - is each element of your cell array a numeric scalar or numeric array? See cell2mat which provides some examples on how you might do this conversion.

추가 답변 (2개)

Damdae
Damdae 2019년 7월 27일

7 개 추천

Try str2double:
cell2mat({'01'}) = '01' (double)
str2double({'01'}) = 1 (char)

댓글 수: 1

Thanks Damdae, very useful tip to convert
cell array, containg numbers, to double.
Best.

댓글을 달려면 로그인하십시오.

Philipp Prestel
Philipp Prestel 2023년 6월 24일

0 개 추천

The absolute easiest way I know is comma seperated list assignment, which looks like this;
a = [{25}; {31}; {24}; {5}; {23}; {64}; {12}; {53}; {22}];
b = [a{:}]'
b = 9×1
25 31 24 5 23 64 12 53 22
I don't know whrether it is any good, but it works if the values of all cells are of the same type. just keep in mind that it will transpose a columnvector to a rowvector.

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2017년 7월 19일

답변:

2023년 6월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by