Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
Lara Lirnow
Lara Lirnow el 19 de Feb. de 2017
Respondida: Walter Roberson el 20 de Feb. de 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

Respuestas (1)

Walter Roberson
Walter Roberson el 20 de Feb. de 2017
A{k} = seg1;

Community Treasure Hunt

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

Start Hunting!

Translated by