1 / 31

ME 392 Adaptable Matlab Programing March 19, 2012 week 10

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.

erik
Download Presentation

ME 392 Adaptable Matlab Programing March 19, 2012 week 10

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ME 392Adaptable Matlab Programing March 19, 2012week 10 Joseph Vignola

  2. 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

  3. 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: Name Date What the document is Lab partner

  4. 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 Word Data M-files including subfunction VI’s including subs

  5. 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 plane Complex measurement system like an ultrasound scanner Power plant

  6. Sub-functions Sub-functions do several things for you Lets you quickly reuse code

  7. Sub-functions Sub-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);

  8. Sub-functions Sub-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);

  9. Sub-functions Sub-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);

  10. Sub-functions Sub-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 and in this case just three line long function [f,t] = freqtime(si,N) t = [0:N-1]’*si; f = t/(si*si*N);

  11. Sub-functions Sub-functions do several things for you Lets you quickly reuse code 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 them The sub-function is a separate m-file and in this case just three line long So you can have “t” in the sub And “time” in the main program function [f,t] = freqtime(si,N) t = [0:N-1]’*si; f = t/(si*si*N);

  12. Sub-functions Sub-functions do several things for you Lets you quickly reuse code The way subs work is that the first input to the function in the main program goes to the first input of the function 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);clf za(1) = axes; plot(time,signal);grid xlabel(… za(2) = axes; plot(freq,abs(SIGNAL));grid xlabel(… So you can have “t” in the sub And “time” in the main program function [f,t] = freqtime(si,N) t = [0:N-1]’*si; f = t/(si*si*N);

  13. Sub-functions Sub-functions do several things for you Lets you quickly reuse code First input to first input 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);clf za(1) = axes; plot(time,signal);grid xlabel(… za(2) = axes; plot(freq,abs(SIGNAL));grid xlabel(… So you can have “t” in the sub And “time” in the main program function [f,t] = freqtime(si,N) t = [0:N-1]’*si; f = t/(si*si*N);

  14. Sub-functions Sub-functions do several things for you Lets you quickly reuse code First input to first input, second to the second 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);clf za(1) = axes; plot(time,signal);grid xlabel(… za(2) = axes; plot(freq,abs(SIGNAL));grid xlabel(… So you can have “t” in the sub And “time” in the main program function [f,t] = freqtime(si,N) t = [0:N-1]’*si; f = t/(si*si*N);

  15. Sub-functions Sub-functions do several things for you Lets you quickly reuse code First output to first output 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);clf za(1) = axes; plot(time,signal);grid xlabel(… za(2) = axes; plot(freq,abs(SIGNAL));grid xlabel(… So you can have “t” in the sub And “time” in the main program function [f,t] = freqtime(si,N) t = [0:N-1]’*si; f = t/(si*si*N);

  16. Sub-functions Sub-functions do several things for you Lets you quickly reuse code First output to first output, second to the second 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);clf za(1) = axes; plot(time,signal);grid xlabel(… za(2) = axes; plot(freq,abs(SIGNAL));grid xlabel(… So you can have “t” in the sub And “time” in the main program function [f,t] = freqtime(si,N) t = [0:N-1]’*si; f = t/(si*si*N);

  17. Sub-functions Sub-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

  18. Sub-functions Sub-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

  19. Sub-functions Sub-functions do several things for you Lets you quickly reuse code Lets you use code that you know works Simplifies the main program This is not important if your code is only a few lines long

  20. Sub-functions Sub-functions do several things for you Lets you quickly reuse code Lets you use code that you know works Simplifies 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

  21. Sub-functions Sub-functions do several things for you Lets you quickly reuse code Lets you use code that you know works Simplifies 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

  22. Matlab Path Functions 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.

  23. Setting the Matlab Path Functions 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.

  24. Gain Measurement Assignment 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.

  25. Gain Measurement Assignment 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

  26. Gain Measurement Assignment 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.

  27. Gain Measurement Assignment 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

  28. Gain Measurement Assignment 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)

  29. Look at the signals It is very important to look at the signals as you work

  30. Look at the signals It is very important to look at the signals as you work Be sure the power amp is at full gain

  31. Look at the signals It is very important to look at the signals as you work Be sure the power amp is at full gain Look at the wiring Be sure the input selector is set to the something you are connected to

More Related