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

78 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

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

Más respuestas (1)

Sriram Tadavarty
Sriram Tadavarty el 28 de Jul. de 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
  1 comentario
Eddie Martin
Eddie Martin el 29 de Jul. de 2020
Thanks for the help, Stephens answer worked very simply.
E1 = T{1,2};
Returns the cell as a numerical value.

Iniciar sesión para comentar.

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by