Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
Lara Lirnow
Lara Lirnow le 19 Fév 2017
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

Réponses (1)

Walter Roberson
Walter Roberson le 20 Fév 2017

Community Treasure Hunt

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

Start Hunting!

Translated by