Remove the variable column generated by the rows2vars function
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Joel Affolter
le 16 Août 2019
Réponse apportée : Kritika Bansal
le 20 Août 2019
I am currently writing a script which imports data from an Excel file and stores the multiple arguments in a structure. Using the input arguments, some calculations are done and the imported results are added to the structure. The goal is to export the data as a excel file, which has the same name as the input file + 'Results' in front of it.
I've done so by converting the structure into a table and then writing an new excel file with abovehand mentionned 'Results' extension. However, I like it far more if the data is exported vertically and not horizontally, which is why I used the
rows2vars
function. The problem is that a "variable column" is generated in the beginning. I would like to remove this column if possible. Does anybody know a way to work around this?
1 commentaire
Réponse acceptée
Kritika Bansal
le 20 Août 2019
Hi,
Assuming you are MATLAB R2018a or later versions, you can use writetable function once you convert your structure to table. Following is the code to write your structure to an excel file without the first column:
%dummy structure
S.Name = {'CLARK';'BROWN';'MARTIN'};
S.Gender = {'M';'F';'M'};
S.SystolicBP = [124;122;130];
S.DiastolicBP = [93;80;92];
T = struct2table(S); %convert structure to table
V = rows2vars(T);
V = V(:,2:end);
writetable(V, 'test.xls');
You can find the documentation of the functions used in above code in the following links:
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Type Conversion 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!