why doesnt it work

4 views (last 30 days)
raad  abzakh
raad abzakh on 18 Jan 2022
Commented: David Hill on 19 Jan 2022
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 Comments
Walter Roberson
Walter Roberson on 18 Jan 2022
The line
Function for DTMF:
is not a valid executable line. You need to comment it out.
Cris LaPierre
Cris LaPierre on 18 Jan 2022
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.

Sign in to comment.

Answers (1)

David Hill
David Hill on 18 Jan 2022
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 Comments
raad  abzakh
raad abzakh on 19 Jan 2022
% 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 on 19 Jan 2022
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);

Sign in to comment.

Tags

Products

Community Treasure Hunt

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

Start Hunting!