- Create cell array from file - MATLAB readcell - MathWorks India
- Convert character array or string to numeric array - MATLAB str2num - MathWorks India
How to read a cell from excel that contains a vector
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Robert Jones
le 5 Juil 2023
Commenté : Robert Jones
le 5 Juil 2023
Hello,
I need to read a cell from an excel file, say D4.
The content of D4 is "[2 4 7]" (the doublequotes are just for specification of the cell content, they are not in the cell)
How can I read this cell in Matlab and create a vector A=[2 4 7]?
Thank you
0 commentaires
Réponse acceptée
Khushi Yadav
le 5 Juil 2023
I understand that you are trying to read the content of a specific cell (D4) from an Excel file in MATLAB and create a vector with the value from this cell. You can use the 'readcell' function to read data from an Excel file into a cell array in MATLAB.
Here’s an example code that you can use:
data = readcell('filename.xlsx');
A = str2num(data{4,4}(2:end-1));
The indexing (2:end-1) is used to remove the square brackets from the string before conversion.
You can refer to the following documentation for more information:
I hope this addresses your question!
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!