Expected nsemitones to be one of these types: single, double

조회 수: 6 (최근 30일)
Rezaul Reza
Rezaul Reza 2022년 1월 1일
답변: Rik 2022년 1월 2일
To change the pitch I am uaing a spinner. However, I am getting this.
Expected nsemitones to be one of these types:
single,
  댓글 수: 8
Rik
Rik 2022년 1월 2일
That was indeed what I meant. Benjamin, do you want to post the solution as the answer, or shall I? Then Rezaul can mark it as accepted answer.
Voss
Voss 2022년 1월 2일
Rik, go for it. You had the solution first, I merely restated it.

댓글을 달려면 로그인하십시오.

답변 (1개)

Rik
Rik 2022년 1월 2일
The reason this code works when you use input (with str2double) is that you have a number.
The code you posted uses the handle to the spinner, meaning you're trying to use the entire object. That doesn't just contain your chosen value but also many other properties (like the position etc).
If you use app.PitchSpinner.Value instead, that will retrieve the actual value. If you use that, your code should work again.
For the next time: if you use the debugger, you can step through your code line by line and have a look at the variables you have in your workspace. If you store app.PitchSpinner in a separate variable, you will see (e.g. by using class(app.PitchSpinner)) that the class of your variable is an object, not a number.

카테고리

Help CenterFile Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by