From: Sean Douglas on 26 Jul 2010 23:55 hey guys, I have a code that is working great, I can load two excel files into matlab and then run my test on the 2 files. I now would like to run this code on lots of excel files, i want to load in say 20 different files and then run each file against each other. My idea is to use a for loop and then to just keep changing the files that matlab drags in, the problem is matlab does not seem to like me doing this with text or string variables? let me show you the beginning part of my code that works: format long g start1=20070101 upto1=20100601 [num, txt]=xlsread('TSO'); tday1=txt(2:end, 1); tday1=datestr(datenum(tday1, 'mm/dd/yyyy'), 'yyyymmdd'); tday1=str2double(cellstr(tday1)); adjcls1=num(:, end); [num2, txt2]=xlsread('VLO'); tday2=txt2(2:end, 1); tday2=datestr(datenum(tday2, 'mm/dd/yyyy'), 'yyyymmdd'); tday2=str2double(cellstr(tday2)); adjcls2=num2(:, end); [tday, idx1, idx2]=intersect(tday1,tday2); adjcls1=adjcls1(idx1); adjcls2=adjcls2(idx2); end of my example, ... see above where I have: xlread('TSO') and a little below that I have: xlread('VLO'), where i read these excel files into matlab, Is there a way i can use varialbes for the strings and do something similar to making the code : x='TSO' y='VLO' .... then in my code use: [num, txt]=xlread('x') ...... [num, txt]=xlread('y') when i do this i get an Error using xlread, indicating matlab can not find xlread('x'), but when i indicate xlread('x') i really want matlab to read in xlread('TSO') because i set x ='TSO' please advise and help me around this Thank you guys
From: Walter Roberson on 27 Jul 2010 00:07 Sean Douglas wrote: > x='TSO' > y='VLO' > .... then in my code use: > [num, txt]=xlread('x') ...... > [num, txt]=xlread('y') [num, txt] = xlsread(x); [num2, txt2] = xlsread(y);
From: us on 27 Jul 2010 03:38 "Sean Douglas"^ > x='TSO' > ... then in my code use: > [num, txt]=xlread('x') > when i do this i get an Error... yes... X is a variable (a character string) , which is assigned to the file name... therefore, proper syntax is [num,txt]=xlsread(x); us
|
Pages: 1 Prev: Multiple generation of function calls in singular time step Next: simulink to m-script doubt |