필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Lara Lirnow
Lara Lirnow 2017년 2월 19일
답변: Walter Roberson 2017년 2월 20일
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