How do I import excel data to a table which has vectors as entries?
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Here is an example of what I am thinking:
mystruct.list = [1 2 3 4 5];
mytable = struct2table(mystruct);
mytable
If you run this short snippet you print the table 'mytable' which will be a single row where each of these rows belows to the single column of the table titled 'list'. What I want to do is the reverse:
newstruct = table2struct(importedtable);
but this time mytable is imported from excel (or another program like it). The problem I'm encountering is a way to format the data in excel or modify the import procedure so that 'importedtable' has the same form as mytable.
Fortunately for me, the data I'm using is not big (the actual vectors are 1x5) so I can probably just write a script which carries this out for me but I'd like it to be simpler if possible. Also the data I'm importing are strings, not numbers.
2 commentaires
Mathieu NOE
le 13 Déc 2021
Modifié(e) : Mathieu NOE
le 13 Déc 2021
hello
not sure to understand what you are trying to do
maybe you should share the excel file and write how the result should be
Priyanka Kondapalli
le 15 Déc 2021
Hello,
I understand that you are having data in excel and want to load into MATLAB table with a single column.
You can use "xlsread()" function to load excel data into MATLAB. This function stores data in the form of matrix.
If the data in excel is in a column, you will get a column vector in MATLAB, below code should do the task
>>data = xlsread(filename)
>>array2table(data);
If the data in excel is in a row, you will get a row vector in MATLAB, then just apply the transpose after loading into MATLAB
>>data = xlsread(filename)
>>array2table(transpose(list));
Hope this solution helps
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!