Author Topic: [help] how load variable .xlsx file name in matlab?  (Read 928 times)

Offline ashkan.nm

  • Newbie
  • *
  • Posts: 1
  • Matlab Forum
    • View Profile
[help] how load variable .xlsx file name in matlab?
« on: January 13, 2012, 02:24:55 PM »
Hello
 i have a lot of Excel files and i need put all of these files in one Excel file
 i want use function xlsread('filename')
 the filenames are
 u 0.1 - u 0.2 - u 0.3 andd ....
 i want write a code that read first file from folder and put the array in on matrix and the read next file in a Loop
 i write a code like below
 --------
 j=0.1
 for i=1:10
 str=num2str(j);
 [num,titl,sub]=xlsread('u str')
 j=j+0.1;
 A(:,i)=num;
 end
 ---------

Offline dave30

  • Newbie
  • *
  • Posts: 2
  • Matlab Forum
    • View Profile
Re: [help] how load variable .xlsx file name in matlab?
« Reply #1 on: February 10, 2012, 11:59:13 PM »
Hello
 
I have an example of script Matlab for read great file *.xls.
 
% This part read all file *.xls from a directory.
list=dir([direc,'*.xll']);
list=list(~cellfun(@isempty,{list( :) .date}));
% Number fille *.xls
numfile=length(list);
 
for na=1:numfile
% read file  *.xls
fname=list(na,1).name;
% fname='R01_W00_S00.xls';
 
data=xlsread(fname);
% Import the columns  odd and even at other variables (cor1 and cor2)
cor1=data(:,1:2:end);
cor2=data(:,2:2:end); 
end

Regard
Dave Correa
correa.dave30@gmail.com
Matlab Programming Service
http://fismatlab.blogspot.com
 
 
 
 

Matlab and SimuLink Development Forum

Re: [help] how load variable .xlsx file name in matlab?
« Reply #1 on: February 10, 2012, 11:59:13 PM »