Remove the variable column generated by the rows2vars function
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Joel Affolter
el 16 de Ag. de 2019
Respondida: Kritika Bansal
el 20 de Ag. de 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 comentario
Respuesta aceptada
Kritika Bansal
el 20 de Ag. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Type Conversion 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!