"Slider control can not have a Value outside of Min/Max Range"
2 ビュー (過去 30 日間)
古いコメントを表示
I am getting this error for a code that I know is correct and should work. Why am I getting this? Here is the code:
function TriadF(handles)
% Triad.m
% Play a musical major triad chord
%%Set Parameters
duration = 2; % length of audio duration, s
add1 = true; % adds tonic
add3 = false; % adds major third
add5 = false; % adds perfect fifth
add8 = false; % adds octave
playSound = true; % play sound
f1 = 440; % tonic frequency, Hz
f3 = f1*(5/4); % major third frequency, Hz
f5 = f1*(3/2); % perfect fifth frequency, Hz
f8 = f1*(2); % octave frequency, Hz
%%Calculate function values
fsample = 8000; % sample frequency, Hz (8000 for proper audio)
Nsamples = fsample*duration;
t = linspace(0,duration,Nsamples); % time points
y1 = sin(2*pi*f1*t); % set up sine waves for each frequency
y3 = sin(2*pi*f3*t);
y5 = sin(2*pi*f5*t);
y8 = sin(2*pi*f8*t);
%%Combine to create final signal
y = zeros(1,Nsamples);
% Use a series of if statements to
if add1
y = y + y1;
end
if add3
y = y + y3;
end
if add5
y = y + y5;
end
if add8
y = y + y8;
end
% final wave form should be limited to +/- 1 for proper audio
y = y/max(y);
%%Plot function points
% plot first 200 points of waveform
plot(t(1:200),y(1:200))
xlabel('t')
ylabel('y')
%%play sound
if playSound
sound(y)
end
0 件のコメント
回答 (2 件)
Image Analyst
2013 年 4 月 17 日
There is no mention of handles, much less a slider, in your function. The code you posted will not cause the error you mention. It must be caused by some other code.
1 件のコメント
Image Analyst
2013 年 4 月 17 日
There's no mention of setting a slider value in that code, your "Answer". If you get an error, it's because it's already set up that way (improperly) in GUIDE with the value property being outside of your min and max range. Tell me, in GUIDE, what are the values of min, max, and value for all the sliders on your GUI.
参考
カテゴリ
Help Center および File Exchange で Measurements and Spatial Audio についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!