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

78 次查看(过去 30 天)
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.

采纳的回答

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

更多回答(1 个)

Sriram Tadavarty
Sriram Tadavarty 2020-7-28
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

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by