[問題] DTMF 電話撥號

看板MATLAB作者 (mark31731123)時間12年前 (2012/06/11 23:54), 編輯推噓1(102)
留言3則, 2人參與, 最新討論串1/4 (看更多)
小弟我已經得到下列程式碼 symbol = {'1','2','3','4','5','6','7','8','9','*','0','#'}; lfg = [697 770 852 941]; % Low frequency group hfg = [1209 1336 1477]; % High frequency group f = []; for c=1:4, for r=1:3, f = [ f [lfg(c);hfg(r)] ]; end end f' ans = 697 1209 697 1336 697 1477 770 1209 770 1336 770 1477 852 1209 852 1336 852 1477 941 1209 941 1336 941 1477 Fs = 8000; % Sampling frequency 8 kHz N = 800; % Tones of 100 ms t = (0:N-1)/Fs; % 800 samples at Fs pit = 2*pi*t; tones = zeros(N,size(f,2)); for toneChoice=1:12, % Generate tone tones(:,toneChoice) = sum(sin(f(:,toneChoice)*pit))'; % Plot tone subplot(4,3,toneChoice),plot(t*1e3,tones(:,toneChoice)); title(['Symbol "', symbol{toneChoice},'": [',num2str(f(1,toneChoice)),',',num2str(f(2,toneChoice)),']']) set(gca, 'Xlim', [0 25]); ylabel('Amplitude'); if toneChoice>9, xlabel('Time (ms)'); end end set(gcf, 'Color', [1 1 1], 'Position', [1 1 1280 1024]) annotation(gcf,'textbox', 'Position',[0.38 0.96 0.45 0.026],... 'EdgeColor',[1 1 1],... 'String', '\bf Time response of each tone of the telephone pad', ... 'FitBoxToText','on'); 接下來必須要輸入下段程式碼才能撥出聲音 for i=[5 11 8 6 4 7 7 11 11 11], p = audioplayer(tones(:,i),Fs); play(p) pause(0.5) end 我的問題是,要如何單純的輸入數字就直接可以撥號 而不用輸入一大段程式碼才能跑(例如用input...) 請問有哪問高手可以幫忙解決嗎 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 120.107.174.109

06/12 00:03, , 1F
寫個GUI,edit + button
06/12 00:03, 1F

06/12 00:07, , 2F
樓上是說要寫一個介面嗎,我是新手功力沒那麼高耶~~
06/12 00:07, 2F

06/12 00:09, , 3F
最好是能在matlab直接打1234...,之後按ENTER就直接撥
06/12 00:09, 3F
文章代碼(AID): #1FrXIWxQ (MATLAB)
文章代碼(AID): #1FrXIWxQ (MATLAB)