Effacer les filtres
Effacer les filtres

How to change underlying char data to double with cells

1 vue (au cours des 30 derniers jours)
Kan
Kan le 24 Oct 2019
Commenté : Walter Roberson le 30 Oct 2019
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!

Réponse acceptée

Sahithi Kanumarlapudi
Sahithi Kanumarlapudi le 30 Oct 2019
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 commentaire
Walter Roberson
Walter Roberson le 30 Oct 2019
str2double can process cell array of character vectors.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by