Read Variables with assigned values from excel into Matlab
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ajiket Patil
le 4 Fév 2021
Modifié(e) : Ajiket Patil
le 4 Fév 2021
I want to read variables with assigned values from excel file (in multiple sheets) into Matlab. In the below snip Var1, Var2 and Var 3 have assigned values 10,5 and 21 respectively.
Kindly inform if it is possible. Thank You.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/509327/image.jpeg)
0 commentaires
Réponse acceptée
Stephen23
le 4 Fév 2021
Modifié(e) : Stephen23
le 4 Fév 2021
Note how the file itself contains invalid variable names: they contain space characters which in all of your comments you have simply ignored. Computers however do not just ignore things in the way that humans like to do, and this hints at some of the reasons why some issues with this approach (how to handle invalid names? How to handle conflicting/identical names? etc.).
Here is one simple method which creates an easy-to-use table of the imported data:
tbl = readtable('test.xlsx','ReadRowNames',true);
tbl = rows2vars(tbl,'VariableNamingRule','modify')
And accessing the values:
tbl.Var1
tbl.Var5
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!