필터 지우기
필터 지우기

How to change underlying char data to double with cells

조회 수: 1 (최근 30일)
Kan
Kan 2019년 10월 24일
댓글: Walter Roberson 2019년 10월 30일
Hi,
How to change underlying char data to double with cells:
The struct I have is:
roofM.materials.volumetricHeatCapacity = is a cell
roofM.materials.volumetricHeatCapacity{1} = is a char (e.g. '3456')
I want to change the char to double for futher processing.
can't seem to get it to work, any help is appreciated!

채택된 답변

Sahithi Kanumarlapudi
Sahithi Kanumarlapudi 2019년 10월 30일
strnum can be used to convert data of type ‘char’ to ‘double’
So in your case you can apply this function to each element of the cell using cellfun
The following line converts your data from char to double
cellfun(@str2num, roofM.materials.volumetricHeatCapacity);
For more information on cellfun and strnum refer to the following links
Hope this helps!
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 10월 30일
str2double can process cell array of character vectors.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by