How to load same/common variables from multiple file without overwriting the previous values

I have three sudio files and each have the same variables('measuredSystem_L','measuredSystem_R').I want to store the values of the variables in same matrix without the previous value being overwritten.I will state the situation.
I have written a code for this script but the previous values are getting overwritten.How can I keep such a script where all the values of the same variables are stored respective to the audiofile. My code:
matfiles=dir('*audiointerface*.mat');
N=length(matfiles);
filenames=cell(N,1);
for i=1:N
filenames{i}=matfiles.name; data=load(matfiles(i).name);
end

 채택된 답변

Use a cell array and indexing:
data = cell(N,1);
for k = 1:N
data{k} = load(matfiles(k).name);
end

댓글 수: 3

I want to get the values of the variables 'measuredSystem_L' and 'measuredSystem_R'which are contained in each of the audiofiles mentioned above without being overwriten
matfiles = dir('*audiointerface*.mat');
N = numel(matfiles);
C = cell(N,2);
for k = 1:N
S = load(matfiles(k).name);
C{k,1} = S.measuredSystem_L;
C{k,2} = S.measuredSystem_R;
end
I would now try to plot the values stored in cell C{k,1} and C{k,2} in frequency domain using fft function.But I am not sure how to plot a value in a cell to that into frequency domain.My main goal is to compare ALL the values of C(k,1) in frequency domain and compare them

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

추가 답변 (1개)

matfiles = dir('*audiointerface*.mat'); N = numel(matfiles); C = cell(N,2); for k = 1:N S = load(matfiles(k).name); C{k,1}=matfiles(k).name C{k,2} = S.measuredSystem_L; C{k,3} = S.measuredSystem_R; end This gave me complete information of the variables and also which file it belonged to

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2018년 4월 25일

답변:

2018년 4월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by