-
[MATLAB] Read & Write Microsoft Excel(cvs, xls) files리뷰/유용한 Tips 2013. 3. 7. 15:16
Most of wireless communication test devices can export their internal data as cvs fileformat.
And you would need to transfer those data to your computer to manipulate them.
EXCEL < = > MATLAB
You can easily import to or export from a varible which is in MATLAB workspace,
by using built-in function xlsread and xlswrite.
If you have multi files to handle, dir command also useful.
Following is an example for extracting useful data from multiple cvs files which contain signal power in frequency domain. I captured the data by using an Agilent spectrum analyzer.
% Load all list of files in this directory
files = dir;
% it could be helpful to initialize
% variable length values before using.
merge = zeros(DATA_LEN,size(files,1)-1);
for i = ST_IDX:size(files,1)
data = xlsread(files(i).name);
realData = data(DATA_LOC, 2);
merge(:,i-1) = realData;
end
merge(:,1) = data(DATA_LOC, 1);
xlswrite(FILE_NAME,merge);
Loaded data at variable merge also could be used in MATLAB.
Isn't that easy ? ha