convert 1x1 Cell with scientific number as text to a number in MATLAB.

124 visualizzazioni (ultimi 30 giorni)
So I have a small doc with some orthotropic material data inside and I am working on changing the axis of the material for a simulation. However for one of the properties, some calculations need to be done so I need the data as a number in matlab rather than just assiging the values to a temp then reassigning them to their new positions. I am struggling to find a way to access this value as a number in order to use it in calculations.
Here is my code:
clear;
clc;
% I have also used readtable and got a similar result
T = readcell('ExampleFile.xlsx', 'range', 'A1:C11'); %Range is included as more info is in the full doc
E1 = T(1,2); % Shows as {[1.1988e+11]}
%% EDIT: Answer below uses E1 = T{1,2}; To correctly call the cell contents as a numerical Value
I would like E1 to be a number.
I have attached the simple example file which is in the format I would recieve.
Any help and advice is appreciated.

Risposta accettata

Stephen23
Stephen23 il 28 Lug 2020
Just use the correct indexing for accessing the contents of a cell array:
E1 = T{1,2};

Più risposte (1)

Sriram Tadavarty
Sriram Tadavarty il 28 Lug 2020
Hi Eddie,
To convert cell to a number, you can use cell2mat function. For usage of the function, look https://www.mathworks.com/help/matlab/ref/cell2mat.html
For your question, try E1 = cell2mat(T(1,2));
Hope this helps. Regards, Sriram

Categorie

Scopri di più su Data Type Conversion in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by