Upload
erik
View
44
Download
0
Embed Size (px)
DESCRIPTION
ME 392 Adaptable Matlab Programing March 19, 2012 week 10. Joseph Vignola. Assignments . I would like to offer to everyone the extra help you might need to catch up. Assignment 5 is due March 26, one week from today Lab 3 is March 28, one week from the Wednesday. - PowerPoint PPT Presentation
Citation preview
ME 392
Adaptable Matlab Programing March 19, 2012
week 10
Joseph Vignola
Assignments I would like to offer to everyone the extra help you might need to catch up.
Assignment 5 is due March 26, one week from todayLab 3 is March 28, one week from the Wednesday
File Names, Title Pages & Information
Please use file names that I can search for
For example
“ME_392_assignment_5_smith_johnson.doc”
Please include information at the top of any document you give me. Most importantly:
NameDate What the document isLab partner
Zip File With Everything
Make a zip file with everything relevant to the assignment and make the file names easy to search for
For example
“ME_392_assignment_5_smith_johnson.zip”
Please include :
Main document MS WordDataM-files including subfunctionVI’s including subs
Logical Programing Logical programing is more important than the actual assignments
This is the only way you will get to the point where you can write complex programs that control a multi-faceted system
Flight-control system on a planeComplex measurement system like an ultrasound scannerPower plant
Sub-functionsSub-functions do several things for you
Lets you quickly reuse code
Sub-functionsSub-functions do several things for you
Lets you quickly reuse code
Things like making the time and frequency vectors
function [f,t] = freqtime(si,N) t = [0:N-1]’*si; f = t/(si*si*N);
Sub-functionsSub-functions do several things for you
Lets you quickly reuse code
Things like making the time and frequency vectors
function [f,t] = freqtime(si,N) t = [0:N-1]’*si; f = t/(si*si*N);
Sub-functionsSub-functions do several things for you
Lets you quickly reuse code
Things like making the time and frequency vectors
The sub-function is a separate m-file
function [f,t] = freqtime(si,N) t = [0:N-1]’*si; f = t/(si*si*N);
Sub-functionsSub-functions do several things for you
Lets you quickly reuse code
Things like making the time and frequency vectors
function [f,t] = freqtime(si,N) t = [0:N-1]’*si; f = t/(si*si*N);
The sub-function is a separate m-fileand in this case just three line long
Sub-functionsSub-functions do several things for you
Lets you quickly reuse code
function [f,t] = freqtime(si,N) t = [0:N-1]’*si; f = t/(si*si*N);
The sub-function is a separate m-fileand in this case just three line long
As a general matter, variable names don’t need to be the same inside the sub-function as they are in the function that calls themSo you can have “t” in the subAnd “time” in the main program
Sub-functionsSub-functions do several things for you
Lets you quickly reuse code
function [f,t] = freqtime(si,N) t = [0:N-1]’*si; f = t/(si*si*N);
The way subs work is that the first input to the function in the main program goes to the first input of the function
So you can have “t” in the subAnd “time” in the main program
A = 1;fc = 1000;[freq,time] = freqtime(dt,num_of_samp);signal = A*sin(2*pi*fc*time) + noise(1,N);SIGNAL = fft(signal)*2/num_of_samp; zf(1) = figure(1);clfza(1) = axes;plot(time,signal);grid xlabel(…za(2) = axes;plot(freq,abs(SIGNAL));grid xlabel(…
Sub-functionsSub-functions do several things for you
Lets you quickly reuse code
function [f,t] = freqtime(si,N) t = [0:N-1]’*si; f = t/(si*si*N);
First input to first input
So you can have “t” in the subAnd “time” in the main program
A = 1;fc = 1000;[freq,time] = freqtime(dt,num_of_samp);signal = A*sin(2*pi*fc*time); SIGNAL = fft(signal)*2/num_of_samp; zf(1) = figure(1);clfza(1) = axes;plot(time,signal);grid xlabel(…za(2) = axes;plot(freq,abs(SIGNAL));grid xlabel(…
Sub-functionsSub-functions do several things for you
Lets you quickly reuse code
function [f,t] = freqtime(si,N) t = [0:N-1]’*si; f = t/(si*si*N);
First input to first input, second to the second
So you can have “t” in the subAnd “time” in the main program
A = 1;fc = 1000;[freq,time] = freqtime(dt,num_of_samp);signal = A*sin(2*pi*fc*time); SIGNAL = fft(signal)*2/num_of_samp; zf(1) = figure(1);clfza(1) = axes;plot(time,signal);grid xlabel(…za(2) = axes;plot(freq,abs(SIGNAL));grid xlabel(…
Sub-functionsSub-functions do several things for you
Lets you quickly reuse code
function [f,t] = freqtime(si,N) t = [0:N-1]’*si; f = t/(si*si*N);
First output to first output
So you can have “t” in the subAnd “time” in the main program
A = 1;fc = 1000;[freq,time] = freqtime(dt,num_of_samp);signal = A*sin(2*pi*fc*time); SIGNAL = fft(signal)*2/num_of_samp; zf(1) = figure(1);clfza(1) = axes;plot(time,signal);grid xlabel(…za(2) = axes;plot(freq,abs(SIGNAL));grid xlabel(…
Sub-functionsSub-functions do several things for you
Lets you quickly reuse code
function [f,t] = freqtime(si,N) t = [0:N-1]’*si; f = t/(si*si*N);
First output to first output, second to the second
So you can have “t” in the subAnd “time” in the main program
A = 1;fc = 1000;[freq,time] = freqtime(dt,num_of_samp);signal = A*sin(2*pi*fc*time); SIGNAL = fft(signal)*2/num_of_samp; zf(1) = figure(1);clfza(1) = axes;plot(time,signal);grid xlabel(…za(2) = axes;plot(freq,abs(SIGNAL));grid xlabel(…
Sub-functionsSub-functions do several things for you
Lets you quickly reuse code Lets you use code that you know works
You will be making time and frequency vectors for all the remaining labs and assignments
Sub-functionsSub-functions do several things for you
Lets you quickly reuse code Lets you use code that you know works
You will be making time and frequency vectors for all the remaining labs and assignments
You needed to scale, AC couple, integrate and plot accelerometer data for the last. There is no need to re-write all that
Sub-functionsSub-functions do several things for you
Lets you quickly reuse code Lets you use code that you know worksSimplifies the main program
This is not important if your code is only a few lines long
Sub-functionsSub-functions do several things for you
Lets you quickly reuse code Lets you use code that you know worksSimplifies the main program
This is not important if your code is only a few lines long but if you are complex having discreet pieces make for much easier debugging
Sub-functionsSub-functions do several things for you
Lets you quickly reuse code Lets you use code that you know worksSimplifies the main program
This is not important if your code is only a few lines long but if you are complex having discreet pieces make for much easier debugging
It is much easier on Therese or me to help if your code is simple to follow
Matlab PathFunctions look just like variables
So when you have a used defined function will first look for it as a variable
Then Matlab will look in the current directory (the one listed above the command window)
The Matlab will look, in order, in the directories in the path.
Setting the Matlab PathFunctions look just like variables
So when you have a used defined function will first look for it as a variable
Then Matlab will look in the current directory (the one listed above the command window)
The Matlab will look, in order, in the directories in the path.
Gain MeasurementAssignment 5 asks you to find a relationship between the input and the output for a shaker.
The relationship would be a measure of displacement of the shaker as a function of input voltage at several frequencies
The amplifier increases the voltage that comes out of the BNC 2120 box.
Gain MeasurementAssignment 5 asks you to find a relationship between the input and the output for a shaker. The amplifier input should not exceed about 0.250 volts and the frequencies should be in the audio band 20-20,000 Hz
Gain MeasurementAssignment 5 asks you to find a relationship between the input and the output for a shaker. The amplifier input should not exceed about 0.250 volts and the frequencies should be in the audio band 20-20,000 Hz
All the power amps are a little different.
Gain MeasurementAssignment 5 asks you to find a relationship between the input and the output for a shaker. The amplifier input should not exceed about 0.250 volts and the frequencies should be in the audio band 20-20,000 Hz
All the power amps are a little different.
Gain should be about 10
Gain MeasurementAssignment 5 asks you to find a relationship between the input and the output for a shaker. The amplifier input should not exceed about 0.250 volts and the frequencies should be in the audio band 20-20,000 Hz
All the power amps are a little different.
Gain should be about 10 (dimensionless)
Look at the signalsIt is very important to look at the signals as you work
Look at the signalsIt is very important to look at the signals as you work
Be sure the power amp is at full gain
Look at the signalsIt is very important to look at the signals as you work
Be sure the power amp is at full gain
Look at the wiringBe sure the input selector is set to the something you are connected to