convert 1x1 Cell with scientific number as text to a number in MATLAB.
78 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Eddie Martin
el 28 de Jul. de 2020
Editada: Eddie Martin
el 29 de Jul. de 2020
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 comentarios
Respuesta aceptada
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
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
Ver también
Categorías
Más información sobre Environment and Settings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!