How to save the variable from the workspace into csv or excel file
145 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
muhammad choudhry
el 2 de Dic. de 2020
Comentada: Ameer Hamza
el 2 de Dic. de 2020
Hi,
I am using the code below to save one of the variable from the workspace into the
excel file but struggling to save it, what it is doing is saving some gibrish into excel rather then the data.
Code:
close all; clear all; clc;
folder = fullfile('D:','Velocity_Analysis','paraViewpractise');
files = dir( fullfile(folder, '*.csv') );
for ii = 1:length(files)
data = readmatrix(fullfile(files(ii).folder,files(ii).name), 'NumHeaderLines', 1)
res(:,ii)= data(:,3);
end
filename='workspace_variable.xls';
save(filename,'res');
winopen('workspace_variable.xls');
0 comentarios
Respuesta aceptada
Ameer Hamza
el 2 de Dic. de 2020
Editada: Ameer Hamza
el 2 de Dic. de 2020
save() is for saving in a .mat file. You need writematrix() for xls
filename='workspace_variable.xls';
writematrix(res, filename);
For releases older than R2019a, use xlswrite().
8 comentarios
Ameer Hamza
el 2 de Dic. de 2020
You may consider attaching your complete code including the line writematrix. Maybe it will give some hints of the issue.
Más respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets 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!