convert 1x1 Cell with scientific number as text to a number in MATLAB.
77 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Stephen23
on 28 Jul 2020
Just use the correct indexing for accessing the contents of a cell array:
E1 = T{1,2};
More Answers (1)
Sriram Tadavarty
on 28 Jul 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
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!