How to fix following error?
古いコメントを表示
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 件のコメント
Adam Danz
2019 年 3 月 27 日
When I run the code you provided, there is no error. The error message you shared indicates that the source of error is welchparse>segment_info (line 88) and this is not included in the code you provided. Please provide a minimal working examples that produces the error and provide the full copy-pasted error message.
Yasir Ali
2019 年 3 月 27 日
Adam Danz
2019 年 3 月 27 日
There is no picture. A screen shot isn't really useful (if that's what you were going to share). People can't copy/paste a screen shot into their matlab workspace.
採用された回答
その他の回答 (1 件)
Adam Danz
2019 年 3 月 27 日
0 投票
"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.
5 件のコメント
Yasir Ali
2019 年 3 月 28 日
Adam Danz
2019 年 3 月 28 日
@Yasir, Walter and I both came to the same conclusion as to the source of the error. To fix the error, your t vector needs more samples. I don't know enough about your data to make a recommendation.
I understand you want your t vector to be in ms resolution. But I can't suggest how to convert whatever you've got into ms resolution without knowing more about the data.
I'm really against proposing solutions that merely prevent an error message from appearing. I think that's a really really bad approach at problem solving and data analysis. The better approach is to figure out what your code is supposed to be doing, what the variables are supposed to represent, and basing the troubleshooting off of that.
So, forget about the error for a moment. What is your t value supposed to represent? What do you think its bounds should be (it's endpoints)? How many values do you think it should have (roughly)? What does the variable represent?
Adam Danz
2019 年 3 月 28 日
Walter is a senior in this forum. I'm a novice compared to him :D
INow I understand that your data have a duration of 5 seconds and that you want the time variable to be at ms resolution. One more bit of information is missing: the interval of your data or the number of samples.
For example
t = 0:0.001:5;
length(t) % = 5001
gives you 5 seconds at 1ms intervals while
t = 0:0.005:5;
length(t) % = 1001
gives you 5 seconds at 5 ms intervals.
Or maybe you want 501 samples between 0 and 5 sec. That would be
linspace(0,5,501)
For now don't worry about being new at Matlab. I think the more important step is to be able to explain what you're trying to do (without worrying how to do it, for now).
Yasir Ali
2019 年 3 月 29 日
カテゴリ
ヘルプ センター および File Exchange で Descriptive Statistics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!