Try our Free Online Math Solver!
Data Analysis With MATLAB
1 Preview: Programming & Experiments Goals
This session is used to introduce basic (MATLAB) programming concepts, including
• Arrays and array manipulations
• 2D plotting
• Script M-files
Basic (Engineering / Science) concepts, including
•Parameter estimation from noisy data
• Matching a mathematical model to data
The driving application involveestimation of the speed of sound in air1 and acoustic distance measurement to remote objects. Specific tasks include
• Measuring the travel time between ultrasound transducers
• Estimating the speed of sound in air from measurement data
• Acoustic distance measurement
Thecomponents & equipment used in this experiment include
• Two sound wave transducers: an emitter (essentially, a small, directional loudspeaker) and a receiver (essentially, a directional microphone); a mark on the basis of each transducer assembly indicates which is the emitter and which is the receiver.
• The emitter is connected to a pre-programmed signal generator
• Both transducers are connected to a digital oscilloscope
• A measuring tape (metric), glued to the lab bench
• A clip board
•MATLAB, installed on the computer.
Experiment Outline:The emitter transducer emits a short burst of several cycles of a sound wave at a 40kHz frequency2. The receiver, located at a selected distance from the emitter, picks up the sound wave. The two transducers are connected to the two input channels of a digital oscilloscope. The process is automatically repeated, periodically, every 10 ms. 3 The oscilloscope displays the recorded sound waves from both transducers. Using features of the oscilloscope display you will be able to measure the time it takes travel time of the sound wave from the emitter to the receiver. In principle, a single measurement suffices to compute an estimate of the speed of sound:
travel distance = speed of sound · travel time (2)
In practice, multiple measurements are needed to overcome measurement errors of both the travel time and the distance between the transducers. Moreover, due to the physical structures of the transducers, distance measurements will bebiased, meaning that even without any other inaccuracies, the actual distance between transducers is different from what we can measure by a fixed amount:
|measured travel distance = speed of sound · travel time + bias||
|This last equation is of the general form of a linear graph|
|y = a x + b||(4)|
You will conduct ten experiments and obtain ten values for distance / travel time pairs. You will then use a MATLAB program to optimally fit a linear graph of the form (4) to your data. The quantity “a” in that fit will be your estimate of the speed of sound, as in (3).
Having estimated the speed of sound and the distance measurement bias, acoustic distance measurement to a remote object will again use the formula (3): Now the two transducers will be placed side by side. The emitter’s sound wave will travel to the target object, bounce back and be recorded by the receiver. The travel distance will thus be twice the distance to the remote object. Having measured the travel time, we can thus conclude
distance to remote object = 0.5 (speed of sound · travel time + bias) (5)
The representation of the relationship between travel distance and travel time in the basic formula (3) is amathematical model. Your final task in this lab will be find an alternative mathematical model, relating the distance to the peak amplitude of the return sound wave, instead of to the travel time.
Programming:The data recording and processing required in this experiment require an introduction to some of the essential building blocks of programming, in any programming language. We shall use this lab as an opportunity to introduce these concepts, as explained below.
2 Homework Assignment
From Lab 2 and on, our practice will be to go through relevant components of the text bookbefore the lab meeting, and include assigned preparatory work by then. Since this is our first meeting, the primer component of Lab 1 is included in the work for the final lab report. In preparation of your report
• Read this entire handout carefully.
• Do the following in a Pre-Lab assignments
– Read4 in the course textMATLAB: An Introduction with Applications
* Chapter 1
* Chapter 2
* Optional Section 4.3.1 (pp. 91-93) (We shall discuss the necessary material in class)
* Optional: 2D Plots, pp. 119-124 (We shall discuss the necessary material in class)
– Do the following problems (include a printout of the MATLAB command window with the solution of each problem):
* Problems 1-5 and 1-15 on pages 28, 30
* Problems 2-1, 2-3, 2-14 on pages 53, 54
• Following completion of the Lab, write a Post-Lab report, summarizing the experiments and your findings, as explained below.
3 Measuring The Speed of Sound: The Experiment
You will conduct ten experiments and record your data in your notebook. Later you will analyze these data using MATLAB.
Attention:Make sure you record all your measurements in the standard meters, seconds and Volts units!
1. Position the emitter so that its face will be directed along the measuring tape and the front of its base is flush with the 0 position.
2. Position the receiver at a point of your selection along the measuring tape, anywhere between 5 - 50cm, facing the emitter. (The position is measured from the front of the transducer’s base.)
The oscilloscope displays both the emitter signal (Channel 1) and the receiver signal (Channel 2). You will notice the record of the short interval of a high amplitude emitter waveform, early on (on the left), followed by an essentially (close to) zero reading and then, an area of increased amplitude waveform, more to the right. This second waveform is the record of the sound wave sensed by the receiver.
3. Read the time it takes sound to travel from the emitter to the receiver:
(a) Press thecurser bottom
(b) Under the display window, select t1
(c) Use the “entry” knob to bring one vertical cursor in the oscilloscope window to the point where, by your visual judgement, the emitter burst begins
(d) Under the display window, select t2
(e) Use the “entry” knob to bring the second vertical cursor in the oscilloscope window to the beginning of the
elevation in the response, in Channel 2.
(f) The corresponding time difference - the sought travel time - appears as “” in the oscilloscope display window. (Pay attention to the time units used: 1 ms = 1e-3 s; 1μs = 1e-6 s.)
4. Record the data pair, consisting of the sound travel time (in seconds!) and the distance between the fronts of the bases of the two transducers (in meters!)
Using a calculator , estimate the speed of sound from each of the ten experiments, using the formula (1).
5. For later use, record also the peak-to-peak amplitude of the received sound wave
(a) Press thecurser bottom
(b) Under the display window, select v1
(c) Use the “entry” knob to bring one horizontal cursor in the oscilloscope window to the lowest peak of the receiver signal
(d) Under the display window, select v2
(e) Use the “entry” knob to bring the second horizontal cursor in the oscilloscope window to the highest peak of the receiver signal
(f) The corresponding voltage difference appears as “” in the oscilloscope display window. (Pay attention to the voltage units used! Record the peak-to-peak value in Volts.)
4 Acoustic Distance Measurement: The Experiment
Here we shall demonstrate the principles of commercially available acoustic distance measurement devices (with diverse
• Place the standing clipboard at the zero position of the measuring tape, with its face facing the length of the measuring tape.
• Place both the receiver and the emitter, side by side, at a selected position along the measuring tape (5 - 30 cm), facing the clipboard. (The front of their bases is used as the transducers’ position, just as in the previous experiment.)
• Use the oscilloscope to measure the travel time of the sound wave from the emitter to the receiver. Record the distance and travel time in your notebook.
• Repeat the experiment 2 more times , at different distances.
In §5.6 you will compare the actual distance with a distance estimated in terms of the travel time.
1 Actually, the speed of sound varies with temperature and air pressure, and the results obtained will provide an estimate for the altitude and temperature of our lab environment.
2The frequency of 1 Hz (one Hertz) means one cycle per second; 1 kHz (one kilo-Hertz) stands for 1000 cycles per second. Thus the sound wave used in our experiments is of 40,000 cycles per second.
3The notation “ms” stands for “milisecond”, or 0.001 second. We shall later encounter also the “μs”, standing for “microsecond”, which is 1μs = 1 · 10-6 = 1e - 6 sec.
4Here and throughout, preparatory reading is essential for the understanding of class material and the ability to perform tasks in class or in the lab.