Hello,
I am writing a GUI to convert parts of .mat files into excel files.
the variables tht are to be converted are stored in a listbox entitled 'listbox2' To clarify where they came from I am trying to put the name of the .mat file on them as a prefix but I cannot seem to get the output files to show up at all.
Worse, this fails to generate any errors. I run the csvwrite command but nothing happens.
Here is the code:
function convert_button_Callback(hObject, eventdata, handles) % hObject handle to convert_button (see GCBO) % eventdata reserved – to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
filelocation = get(handles.MAT_file, 'string');
loadfile =['load ''' filelocation ''''];
eval(loadfile);
%evaluate the sting as if it were a command. See notes on %apostrophies for this one. %eval(['varlist = who(''-file'' , ''' filelocation ''');']);
exportlist = get(handles.listbox2,'string')
%we need to change the directory to the chosen output and after we have %re-loaded the .mat file into the workspace convert the files %The evalin evaluates the expression in 'base' or workspace
for a = 1:length(exportlist) finaltag = strcat(filelocation, exportlist{a})
outloc = get(handles.CSV_file, 'string'); cdstring = ['cd(''' outloc ''')']; eval(cdstring); csvwrite([finaltag,'.csv'],evalin('base',exportlist{a})) %Orional code
%csvwrite([exportlist{a},'.csv'],evalin('base',exportlist{a}))
end
Best Answer