Hi,
Im new to MATLAB and am trying to extract data from a sine wave. I've set the threshold to -1 SD and want all of the data below it to stack into one matrix. In other words, M has to be a stacked product of P. However, at the last part of the code it gives the error: Index Exceeds Matrix Dimensions. From what I understand, this means that length(P)+P(i)>length(noise). So the logical thing to do would be to make 'noise' bigger or P(i) smaller. However, I can't seem to get rid of the error. I was told not to index so far into P, but i have no idea how to do that. Hopefully someone can help me with this!
clear allhold off% parameters
srate=1000;t=1:99/srate:10;noiseAmplitude=2;a=4;f=4;%signal
signal=a*sin(2*pi*f*t);noise= signal + noiseAmplitude*randn(1,length(signal));standdev=std(noise);P=find(diff(noise<-standdev)==1);for i=1:length(P) M(i,:)=noise(P(i):P(i)+10); (<-- ERROR: index exceeds matrix dimensions)endplot(M)
Best Answer