Code to handle excel using Matlab

I want to handle excel using Matlab because there are lots of excel files and handling these manually is quite tedious.
Uploaded link is showing process that I want to repeat by using Matlab but I'm not good at coding and I don't know function for excel in Matlab.
This video is treating excel file whose name is 'Data001' and I want to repeat this process upto 'Data040'
How can I do?
Thank you~!

댓글 수: 3

Voss
Voss 2023년 1월 6일
What is the extension of the files? Do they have no extension? Or is the extension something like ".txt" and the extension is hidden in Windows File Explorer?
상호 고
상호 고 2023년 1월 6일
Yes it's just text file.
In this video, It is opened by Notepad++
Voss
Voss 2023년 1월 6일
I understand it's a text file, but it's important to know the actual extension.

댓글을 달려면 로그인하십시오.

답변 (1개)

Voss
Voss 2023년 1월 6일

0 개 추천

Try this:
% use the directory where your files are here:
input_file_path = 'C:\2021_11_15\Inlet';
% use the directory where you want the new files to go here:
output_file_path = 'C:\2021_11_15\Inlet_after_handling';
% get info about the relevant files in the input directory
files = dir(fullfile(input_file_path,'Data*.txt')); % if they have .txt extension
% remove any directories returned by dir
% (might happen if the files have no extension):
files([files.isdir]) = [];
% construct full-path file names of input and output files:
input_file_names = fullfile(input_file_path,{files.name});
output_file_names = fullfile(output_file_path,{files.name});
% read each input file and write the corresponding output file:
for ii = 1:numel(files)
A = readmatrix(input_file_names{ii},'FileType','text'); % 'FileType','text' is necessary if the files have no extension
% writing only columns 1,3,2,6,5 in that order
writematrix(A(:,[1 3 2 6 5]),output_file_names{ii},'Delimiter','\t','FileType','text');
end

카테고리

도움말 센터File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

태그

질문:

2023년 1월 6일

답변:

2023년 1월 6일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by