How to fix following error?
68 views (last 30 days)
Show older comments
Yasir Ali
on 27 Mar 2019
Commented: Walter Roberson
on 29 Mar 2019
Hello Seniors, How to Solve following error I tried but failed to solve it.
t=0:0.300:0.050:0500; x=chirp (t,0,1,150); F=0:0.1:100; [y,f,t,p]=spectrogram(x,256,250,F,1E3,'yaxis');
Error using welchparse>segment_info (line 88)The length of the segment cannot be greater than the length of the input signal.
I will provide full code if anyone need actually my problem is to get voice frequency in miliseconds.
4 Comments
Accepted Answer
Walter Roberson
on 28 Mar 2019
You assign a vector to t before the code, but you name t as an output parameter in the spectrogram() call. If you then try to use t after that, it is now only 3 x 1 and you have a problem.
The problem is not the first run: the problem is overwriting t but still expecting t to have the same meaning.
9 Comments
Walter Roberson
on 29 Mar 2019
The general formula is:
time = (0:number_of_samples-1) / sampling_frequency
More Answers (1)
Adam Danz
on 27 Mar 2019
"Error: The length of the segments cannot be greater than the length of the input signal."
When you're using miliseconds, your x input contains 2001 samples and your window value of 256 breaks up the 2001 values into 256 segments. That works fine. The reason your code is breaking with the other set of parameters is that your x input only contains 3 samples but your window value is still 256. As the error message indicates, the number of segments can't be greater than the number of samples in x.
See Also
Categories
Find more on Bartlett in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!