How to load multiple data into separate variable?

Hello, I'm writting a script that will read/load multiple audiofiles from my folders. What I want to have is: I have multiple folders and they contain 4 registrations- e.g. in folder ZO_0034 i have 4 files named ZO_0034_t1, ZO_0034_t2 etc., then in folder ZO_0035 its the same situation. I want the first registration to be load into x1, second x2, etc. This is what I have now:
% clc
file_path='D:\data\ZO_0034\';
file_type = dir('*.wav');
hydrophones=4;
x1=[];
x2=[];
x3=[];
x4=[];
for i = 1:numel(file_type)
[x,Fs] = audioread(file_type(i).name);
end
Any idea how to modificate it to make it work? I will be grateful.

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 27 日
編集済み: Azzi Abdelmalek 2016 年 4 月 27 日

1 投票

It's a bad idea to create several variables, when you can use one (cella array)
% clc
file_path='D:\data\ZO_0034\';
file_type = dir('*.wav');
hydrophones=4;
for i = 1:numel(file_type)
[x,Fs] = audioread(file_type(i).name);
out{i,1}=x;
out{i,2}=Fs
end
Your signals are
out{1,1}
out{2,1}
...
and so on

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

質問済み:

2016 年 4 月 27 日

編集済み:

2016 年 4 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by