How to change the contents of an exported .mat file to an Excel file
Show older comments
Hi,
I wrote a code that converts two .mat files into Excel files from the selected selection of a list named Log. The code is as follows:
function Log_Callback(hObject, eventdata, handles)
g=get(handles.Log,'value')
if (g~=1)
x=get(handles.Log,'String');
y=get(handles.Log,'value');
f=x{y};
if(strcmp(f,'Exchange between FT0 and FT1 "Boolean"'))
set_param('MAJ','SimulationCommand','stop');
stop(handles.t);
set(handles.Stop,'BackgroundColor', 'red');
data=load('FT1Exchange(1).mat');
h=fieldnames(data);
for k=1:size(h,1)
xlswrite('testFT1.xlsx',data.(h{k}),h{k})
end
winopen testFT1.xlsx
elseif(strcmp(f,'Exchange between FT0 and FT1 "Double"'))
set_param('MAJ','SimulationCommand','stop');
stop(handles.t);
set(handles.Stop,'BackgroundColor', 'red');
data=load('FT1Exchange(2).mat');
h=fieldnames(data);
for k=1:size(h,1)
xlswrite('testFT11.xlsx',data.(h{k}),h{k})
end
winopen testFT11.xlsx
end;
end;
I have two questions:
1- The following code converts both .mat into two separate Excel files, how can I insert both .mat into two sheets of the same Excel file?
2- I get as a result the following table:

How can I add a column at the beginning that includes the name of each line?
Thank you for your Help
Accepted Answer
More Answers (0)
Categories
Find more on Data Import from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!