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!
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
SnoopingPoppet
el 15 de Sept. de 2016
Comentada: Rena Berman
el 28 de Sept. de 2017
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 comentarios
Stephen23
el 21 de Sept. de 2017
@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.
Respuesta aceptada
Stephen23
el 16 de Sept. de 2016
Editada: Stephen23
el 16 de Sept. de 2016
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
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!