using Matlab2012a and I am trying to open an excel file, convert to csv and then save the csv file with a new name to a specific subfolder. I am able to open the excel file, convert to csv type and rename…but unable to save the csv file to the subfolder of my choosing. MATLAB defaults saving the file to the highest level folder in the path which is a folder named 'BCIS'. I want to save it to the subfolder 'subFolder1a'
The code I'm using is as follows: …
% reading excel and convert to cell array
[~,readfile,~] = xlsread([FilePath FileName]);
Tfile = readfile(2:end,2);[nrows,~]= size(Tfile);% create dialogue box for user entered file name to save
dlg_title = 'Save Txt File'; num_lines = 1;def = {''}; answer = inputdlg('Please enter a name to save file:',dlg_title,num_lines,def);% Convert file to csv
filename = (answer{1,1});fid = fopen(filename, 'w');for row=1:nrows fprintf(fid,'%s', Tfile{row,:}) end fclose(fid)% save file to subfolder
FilePathText = 'C:\BCIS\subFolder\subFolder1\SubFolder1a\';filename = uiputfile({'*.csv','Data Files (*.csv)'},... 'Save Ticker List As',... [FilePathText filename]);
Any help greatly appreciated.
Best Answer