フィルターのクリア

I cannot get the timing to work correctly(using tic and toc), I cannot get my while ~(B|R|Y|G) to work, which i need it to reiterate 4 times before it BOOM!, Last, need help with making a sound that makes 3 sharp beeps. Thanks!

4 ビュー (過去 30 日間)
tic
switch input('Will you cut the (R)ed, (Y)ellow,(B)lue, or (G)reen wire?-->','s')
%while ~(B|R|Y|G)
%input('Try Again -->');
case 'R'
bomb = 'DISARMED';
case 'Y'
bomb = 'BOOM!';
case 'B'
bomb = 'BOOM!';
case 'G'
tElapsed = toc;
%if (tElapsed>5)
%bomb = 'BOOM!';
end
tic
switch input('Will you cut the (R)ed, (Y)ellow, or (B)lue wire? -->','s')
case 'R'
bomb = 'DISARMED';
case 'Y'
bomb = 'BOOM!';
case 'B'
bomb = 'BOOM!';
otherwise
bomb = 'BOOM!';
tElapsed = toc;
end
otherwise
bomb = 'BOOM!';
if (tElapsed>5)
bomb = 'BOOM!';
end
end
%if bomb = ('DISARMED')
%load handel
%sound(y,Fs);
%else
%beep;beep;beep;
  3 件のコメント
Stephen23
Stephen23 2017 年 9 月 21 日
@Snooping Poppet: it is not appreciated when you edit away the text of your question. Imagine if everyone did that, then this entire forum would be useless for anyone else as it would only consist of thousands of threads all reading "This post was taken down". Would you find that useful?
By deleting your question you unilaterally decided that my volunteered time helping you shall not be useful to anyone else. Do I get a say in this decision? Do you think this is why we volunteers come here and write our advice and comments?
If you want a consulting service then you will find plenty of them on them internet. This is a community forum with answers provided by volunteers.
Rena Berman
Rena Berman 2017 年 9 月 28 日
(Answers Dev) Restored edit

サインインしてコメントする。

採用された回答

Stephen23
Stephen23 2016 年 9 月 16 日
編集済み: Stephen23 2016 年 9 月 16 日
Have a play around with this, you can change the logic very simply:
lim = 5;
arm = true; % is armed.
xpl = false; % is exploding.
txt = 'Will you cut the (R)ed, (Y)ellow,(B)lue, or (G)reen wire? ';
tic
while arm && ~xpl
switch upper(input(txt,'s'));
case 'R'
arm = false;
case {'Y','B'}
xpl = true;
case 'G'
xpl = toc>lim;
otherwise
disp('Try again!')
end
end
if xpl
load handel
sound(y,Fs)
elseif ~arm
beep
beep
beep
end
Note that using tic and toc is not the same as running a timer object.

その他の回答 (0 件)

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by