0% found this document useful (0 votes)
75 views2 pages

Chapter7 Prob17

The document describes a MATLAB user-defined function named Sampling that samples an analytical function over a specified time interval and spacing. It provides a specific example of sampling a function defined by a combination of sine functions with a frequency of 554.365 Hz over a 10 ms interval with 10 μs spacing, and includes a script to execute this sampling and plot the results. Additionally, it includes copyright information regarding the reproduction of the work for educational purposes.

Uploaded by

skibidipapap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views2 pages

Chapter7 Prob17

The document describes a MATLAB user-defined function named Sampling that samples an analytical function over a specified time interval and spacing. It provides a specific example of sampling a function defined by a combination of sine functions with a frequency of 554.365 Hz over a 10 ms interval with 10 μs spacing, and includes a script to execute this sampling and plot the results. Additionally, it includes copyright information regarding the reproduction of the work for educational purposes.

Uploaded by

skibidipapap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1

7.17 Write a MATLAB user-defined function that samples a function that is given in an analytical form.
Name the function [t,f] = Sampling(Fun,tau,dt). The input argument Fun is a name for the function
that is being sampled (it is a dummy name for the function that is imported into Sampling), tau is the
time interval over which the continuous function is prescribed, where the starting time is 0 and the final
time equals the value tau, and dt is the spacing between the sampled points. The output arguments t and
f are vectors with the values of the independent and dependent variables of the sampled function, respec-
tively.
Use Sampling to sample the following function over an interval of 10 ms and spacing of 10 μ s.
5 2 5 2 4 2
– 10 ( t – 0.005 ) – 10 ( t – 0.005 ) – 10 ( t – 0.005 )
f ( t ) = 0.5 sin ( 2πνt )e + sin ( 4πνt )e + 0.2 sin ( 6πνt )e
4 2 4 2
– 10 ( t – 0.005 ) – 10 ( t – 0.005 )
+ 0.1 sin ( 8πνt )e + 0.1 sin ( 10πνt )e
where ν = 554.365 Hz. Make a plot of the sampled points.
Solution
The user-defined function Sampling:

function [t,f]=Sampling(Fun,tau,dt)
t=0:dt:tau;
for i=1:length(t)
f(i)=Fun(t(i));
end

A program in a script file that solves the problem:

clear, clc
v=554.365;
pv=pi*v;
ti=0.005;
foft= @ (t) 0.5*sin(2*pv*t)*exp(-1E5*(t-ti)^2)+sin(4*pv*t)*exp(-1E5*(t-
ti)^2)...
+0.2*sin(6*pv*t)*exp(-1E4*(t-ti)^2)+0.1*sin(8*pv*t)*exp(-1E4*(t-ti)^2)...
+0.1*sin(10*pv*t)*exp(-1E5*(t-ti)^2);
[t,f]=Sampling(foft,10E-3,10E-6);
plot(t,f)

Excerpts from this work may be reproduced by instructors for distribution on a not-for-profit basis
for testing or instructional purposes only to students enrolled in courses for which the textbook
has been adopted. Any other reproduction or translation of this work beyond that permitted by
Sections 107 or 108 of the 1976 United States Copyright Act without the permission of the
copyright owner is unlawful.
2

xlabel('t')
ylabel('f(t)')
t=0:0.25:2;
fa=0:0.25:2;
Complex_DFT(t,fa);

When the file is executed the following figure is displaced:

1.5

0.5
f(t)

-0.5

-1

-1.5
0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 0.01
t

Excerpts from this work may be reproduced by instructors for distribution on a not-for-profit basis
for testing or instructional purposes only to students enrolled in courses for which the textbook
has been adopted. Any other reproduction or translation of this work beyond that permitted by
Sections 107 or 108 of the 1976 United States Copyright Act without the permission of the
copyright owner is unlawful.

You might also like