unusual problem with an unusual solution
Ältere Kommentare anzeigen
i use these 2 codes:
i use these functions together, but after running matlab hangs. i fund that 'close' command in line '69' of waitinput.m caused this that while i delete this command, matlab not hangs but it cause its problems.
i found also an unusual solution is to put a command between cprintf.m calling and waitinput.m function. this commands is:
NET.addAssembly('System.Speech');
speaker = System.Speech.Synthesis.SpeechSynthesizer();
speaker.Rate = 1;
speaker.Volume = 100;
speaker.Speak('hello');
my program is:
clc,clear all
t=5;
cprintf('blue','in %ds type 1 to plot 3 signals in one figure', t);
sel=waitinput('>>',t);
if sel == 1;
figure, plot((1:10),'c')
hold on
plot((5:10),'k')
plot(rand(100,1),'r')
hold off;
legend('a','b','c')
end
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
NET.addAssembly('System.Speech');
speaker = System.Speech.Synthesis.SpeechSynthesizer();
speaker.Rate = 1;
speaker.Volume = 100;
speaker.Speak('');
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cprintf('blue','in %ds type 2 to plot 3 signals separately', t);
sel=waitinput('>>',t);
if sel == 2;
subplot(311)
plot(rand(100,1),'r')
subplot(312)
bar(rand(5,1),'c')
subplot(313)
semilogy(1:10)
end
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
NET.addAssembly('System.Speech');
speaker = System.Speech.Synthesis.SpeechSynthesizer();
speaker.Rate = 1;
speaker.Volume = 100;
speaker.Speak('');
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cprintf('g','**************************************************************************************')
fprintf(1,repmat('\n',1,1));
now when i delete this command between of these 2 (waitinput and cprintf) matlab hangs (because of 'close' command in line 69 of waitinput.m but i dont know for what). i need one of these:
1-finding cause of the problem and solving it
or
2-puting another command between cprintf and waitinput instead of 'NET.addAssembly('System.Speech');' because in some PCs the framework doesn't install.
please give me a hand in one of this way
5 Kommentare
Oleg Komarov
am 6 Sep. 2011
If I run your MATLAB only code it doesn't hang.
mohammad
am 6 Sep. 2011
Oleg Komarov
am 6 Sep. 2011
I tried w/o.
mohammad
am 6 Sep. 2011
Grzegorz Knor
am 7 Sep. 2011
Matlab doesn't hang on my PC too.
Line close(fh) in waitinput.m just close invisible, auxiliary figure.
Akzeptierte Antwort
Weitere Antworten (2)
mohammad
am 7 Sep. 2011
2 Kommentare
Grzegorz Knor
am 7 Sep. 2011
nope... it's OK.
BTW, my output from ver:
MATLAB Version 7.10.0.499 (R2010a)
Operating System: Linux 2.6.38-11-generic-pae #48-Ubuntu SMP Fri Jul 29 20:51:21 UTC 2011 i686
Java VM Version: Java 1.6.0_12-b04 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode
mohammad
am 7 Sep. 2011
Grzegorz Knor
am 7 Sep. 2011
0 Stimmen
OK. There is problem with rob.keyPress in Oleg Komarov answer. When the time comes to an end an error occurs. So if you want to use this solution you have to write function that supports this case.
But I still can not trace the error of waitinput.
3 Kommentare
Oleg Komarov
am 7 Sep. 2011
Edited to include in fcn.
mohammad
am 7 Sep. 2011
mohammad
am 7 Sep. 2011
Kategorien
Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!