Hi every body expert in matlab,
I have excel data (.xls) store in my hard disk, (for example data namely
12_1.xls, 12_2.xls, 12_3.xls ... and 12_6.xls).
As I know to load excel data we use xlsread command , for my own m file:
data_1=xlsread('12_1.xls);
.
.
.
bla.. bla ---> my own script to process the data_1
then I save,
new_name1.txt -ascii data_1
If I want to process the next file (for example , 12_2.xls), I must change
manually my own script m file
data_2=xlsread('12_2.xls); ---> manually change
.
.
.
bla bla my own script to process the data_1
and I save new_name2.txt -ascii data_2 ------> manually change
my question is
Can I load and save my excel data just input the name of data without open and
change the m file manually.
thanks very much for your kind help
load data
Started by ●October 18, 2010
Reply by ●October 27, 20102010-10-27
I'm not 100% clear on what exactly you're looking to do, but one thing you could
do is build a string using sprintf() or something and then pass that to the
xlsread() command, so you don't have to change it every time:
% suppose the data number is saved in the variable 'num', so
% for example, if you're looking to read '12_2.xls', then num = 2
% I'm assuming that your script can decide which is the right number
% file to use.
% build a filename string
filename = sprintf('12_%i.xls',num);
data = xlsread(filename);
<-- your script -->
Hope this helps - like I said, I'm not completely clear on what you're trying to do here. If I misunderstood your question, please let me know and I'll try to help more.
Tom
Hi every body expert in matlab,
>
>I have excel data (.xls) store in my hard disk, (for example data namely 12_1.xls, 12_2.xls, 12_3.xls ... and 12_6.xls).
>As I know to load excel data we use xlsread command , for my own m file:
>
>data_1=xlsread('12_1.xls);
>.
>.
>.
>bla.. bla ---> my own script to process the data_1
>
>then I save,
> new_name1.txt -ascii data_1
>
>If I want to process the next file (for example , 12_2.xls), I must change manually my own script m file
>
>data_2=xlsread('12_2.xls); ---> manually change
>.
>.
>.
>bla bla my own script to process the data_1
>and I save new_name2.txt -ascii data_2 ------> manually change
>
>my question is
>
>Can I load and save my excel data just input the name of data without open and change the m file manually.
>
>thanks very much for your kind help
% suppose the data number is saved in the variable 'num', so
% for example, if you're looking to read '12_2.xls', then num = 2
% I'm assuming that your script can decide which is the right number
% file to use.
% build a filename string
filename = sprintf('12_%i.xls',num);
data = xlsread(filename);
<-- your script -->
Hope this helps - like I said, I'm not completely clear on what you're trying to do here. If I misunderstood your question, please let me know and I'll try to help more.
Tom
Hi every body expert in matlab,
>
>I have excel data (.xls) store in my hard disk, (for example data namely 12_1.xls, 12_2.xls, 12_3.xls ... and 12_6.xls).
>As I know to load excel data we use xlsread command , for my own m file:
>
>data_1=xlsread('12_1.xls);
>.
>.
>.
>bla.. bla ---> my own script to process the data_1
>
>then I save,
> new_name1.txt -ascii data_1
>
>If I want to process the next file (for example , 12_2.xls), I must change manually my own script m file
>
>data_2=xlsread('12_2.xls); ---> manually change
>.
>.
>.
>bla bla my own script to process the data_1
>and I save new_name2.txt -ascii data_2 ------> manually change
>
>my question is
>
>Can I load and save my excel data just input the name of data without open and change the m file manually.
>
>thanks very much for your kind help