How to store data in a matrix, but not to overwrite values

2 次查看(过去 30 天)
I want to save the results of a for loop into a matrix, but the results are always getting overwritten,so only the last value is written. I want to save variable seg1 into a matrix. How can I do it? (This code is splitting audio signal into segments). I tried with this code:
[data,Fs] = audioread('sz08010103404.wav');
list = fopen('intervals.txt','r');
C=cell(size(list))
%split the signal
N = length(data);
totaldur = N/Fs; % total duration
t = linspace(0,totaldur,N); % create a time vector
for k=1:length(list)
content = fgets(list(k))
d= strsplit(content,',')
for n=1:length(d) %d contains 25 elements
y=d{n}
z= strsplit(y,' ')
start=z{1}
stop=z{2}
start1 = str2num(start)
stop1 = str2num(stop)
seg1 = data(t>start1 & t<stop1)
sound(seg1)
A=[seg1] %output needs to go here
end
end

回答(1 个)

Walter Roberson
Walter Roberson 2017-2-20

类别

Help CenterFile Exchange 中查找有关 Multirate Signal Processing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by