function x = ss_dtmf(number,dt,nd,np)
nl = length(number);
x = [];
t = 0:1:nd;
t = t*dt;
tp = 0:1:np;
xp = zeros(1,length(tp));
for i=1:nl
xi = ss_dtmf1(number(i),t);
x = [x,xi];
x = [x,xp];
end
end

5 件のコメント

Cris LaPierre
Cris LaPierre 2022 年 1 月 18 日
Share the complete error message you are getting, as well as the code you use to call the function ss_dtmf.
Also, please share the code for your function ss_dtmf1.
raad  abzakh
raad abzakh 2022 年 1 月 18 日
編集済み: Walter Roberson 2022 年 1 月 18 日
this is everything i have
type firstcode
clc; close all; clear all; %Time limit Td = 2; %Defining time interval t = 0:0.01:Td; % Taking input for key n = input('Enter any number between 0-12: '); %Assigning keys *, # to 10,11 if(n=='*') n = 10; elseif(n=='#') n = 11; end % Calling the function x = ss_dtmf1(n,t); Function for DTMF: function x = ss_dtmf1(n,t) %Defining the frequencies for the keys switch (n) case 1 f1 = 697;f2 = 1209; case 2 f1 = 697;f2 = 1336; case 3 f1 = 697;f2 = 1477; case 4 f1 = 770;f2 = 1209; case 5 f1 = 770;f2 = 1336; case 6 f1 = 770;f2 = 1477; case 7 f1 = 852;f2 = 1209; case 8 f1 = 852;f2 = 1336; case 9 f1 = 852;f2 = 1477; case 10 f1 = 941;f2 = 1209; case 0 f1 = 941;f2 = 1336; case 11 f1 = 941;f2 = 1477; case 12 f1 = 0;f2 = 0; end x = sin(2*pi*f1.*t)+sin(2*pi*f2.*t); figure,plot(t,x); title(['DTMF signal for the key ' num2str(n) 'and the corresponding frequencies are ' num2str(f1) ',' num2str(f2)]); end
raad  abzakh
raad abzakh 2022 年 1 月 18 日
@Cris LaPierre i dont want you to solve it i jyst wanna know what can i do to solve it ive been 4 hours on this
Walter Roberson
Walter Roberson 2022 年 1 月 18 日
The line
Function for DTMF:
is not a valid executable line. You need to comment it out.
Cris LaPierre
Cris LaPierre 2022 年 1 月 18 日
Try commenting out your comments so that you can run your code.
Functions must be called, so I'm asking how you are calling your function ss_dtmf? Specifically what are your input values for number, dt, nd, and np?
What error messages are you getting? Please copy and share all the red text.

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

回答 (1 件)

David Hill
David Hill 2022 年 1 月 18 日

0 投票

function x = ss_dtmf(number,dt,nd,np)
x=[];
for i=1:length(number)
x = [x,ss_dtmf1(number(i),0:nd:dt),ss_dtmf1(12,0:np:dt)];
end
end
function x = ss_dtmf1(n,t)
f=[941,697,697,697,770,770,770,852,852,852,941,941,0;1336,1209,1336,1477,1209,1336,1477,1209,1336,1477,1209,1477,0];
x=sin(2*pi*f(1,n+1)*t)+sin(2*pi*f(2,n+1)*t);
end

4 件のコメント

raad  abzakh
raad abzakh 2022 年 1 月 19 日
do you know how can i solve this with the codes i attached?"
id do anything
David Hill
David Hill 2022 年 1 月 19 日
nd and np are not defined. What do they mean?
raad  abzakh
raad abzakh 2022 年 1 月 19 日
% Generation of DTMF signal for one digit
%
% Input:
% n - number of array
% dt - time increment
% nd - number of samples for each digit
% np - number of samples for each pause
%
% Output:
% x - DTMF signal
David Hill
David Hill 2022 年 1 月 19 日
This should do exactly what you want.
function x = ss_dtmf(number,dt,nd,np)
x=[];
lt=linspace(0,dt,nd);
lp=linspace(0,dt,np);
for i=1:length(number)
x = [x,ss_dtmf1(number(i),lt),ss_dtmf1(12,lp)];
end
plot(x);
end
function x = ss_dtmf1(n,t)
f=[941,697,697,697,770,770,770,852,852,852,941,941,0;1336,1209,1336,1477,1209,1336,...
1477,1209,1336,1477,1209,1477,0];
x=sin(2*pi*f(1,n+1)*t)+sin(2*pi*f(2,n+1)*t);
end
for example:
x=ss_dtmf([2 0 8 7 3 9 6 1 0 3],.1,1000,50);

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

製品

タグ

質問済み:

2022 年 1 月 18 日

コメント済み:

2022 年 1 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by