Code to automatically generate filename from reading cell in an excel file
Mostra commenti meno recenti
Hello, its been a while since I used MATLAB and I seem to be having problems.
What Im trying to do: To read an excel file (specific cells) > name file using a series of those cells.
ie cell 1 = C2, cell 2 = 2013_02_25, cell 3 = WE08GYD >> file saved as C2_2013_02_25_WE08GYD.pdf
The code i'm using:
[~,~,testcll] = xlsread('Book1.xlsx','Sheet2','A1'); % 'C2';
[~,~,testdate] = xlsread('Book1.xlsx','Sheet2','A2'); %'2013_07_07';
[~,~,testnumber] = xlsread('Book1.xlsx','Sheet2','A3'); %21;
testtype = 'FTP75';
[~,~,vehicle] = xlsread('Book1.xlsx','Sheet1','D1'); %'Y654GYD';
% filename = -['WARNING TEST FILE_' testcll(1,1)] % <<<< Failing
% filename = sprintf('WARNING TEST FILE_%s_%s_%s_%s_%s', testcll, testdate,
% testnumber, testtype, vehicle) % <<<< Failing
% filename = ['WARNING TEST FILE_', testcll, '_', testdate, '_',
% testnumber, '_', testtype, '_', vehicle] % <<<< Failing
saveas(tst2, filename, 'pdf')
I've tried several things with sprintf (i think thats what is supposed to be used) but it can't seem to deal with the imported information being in a cell
Any help would be appreciated.
3 Commenti
Iman Ansari
il 18 Apr 2013
Hi. use testcll{1,1} for indexing cell content.
Matthew
il 18 Apr 2013
Risposte (1)
Iman Ansari
il 18 Apr 2013
filename = ['WARNING TEST FILE_C2_2013-02-25']
filename(filename=='-')='_'
Categorie
Scopri di più su Spreadsheets in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!