フィルターのクリア

Automate function and text reading tasks in MATLAB

2 ビュー (過去 30 日間)
Philip Hoskinson
Philip Hoskinson 2015 年 7 月 22 日
コメント済み: Philip Hoskinson 2015 年 7 月 22 日
I need help automating some of my work:
I have several txt files I am using dlmread to bring into matlab, and then manipulate with functions.
Right now I am bringing in each file, and changing my function each time to account for added input.
Example abbreviated:
1) dlmread(file)
2) call the function ( file)
3) function [] = name[filea,fileb,filec]
body: combine/change a, b, c etc
It is tedious to manually add lines of code to step 1 for each file ( many files), and to change step 2 and the function for each new variable.
Is there a way to have matlab automatically take all txt files from a folder, for example, then read them into a function that accounts for the number of files?
I am new into deep programming in MATLAB. Any help would be appreciated.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 22 日
編集済み: Azzi Abdelmalek 2015 年 7 月 22 日
f='C:\Users\Documents\MATLAB' % The folder where your files are located
d=dir(fullfile(f,'*.txt'))
file={d.name}
for k=1:numel(file)
data{k}=dlmread(fullfile(f,file{k}))
end
  1 件のコメント
Philip Hoskinson
Philip Hoskinson 2015 年 7 月 22 日
Issues with {d.name} : "Invalid floating point constant"
'name' refers to what ever I want?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by