EGR_102_Lab_Exam_1_-_MATLAB_Solutions_-_

# EGR_102_Lab_Exam_1_-_MATLAB_Solutions_-_ - Name Section...

This preview shows pages 1–2. Sign up to view the full content.

Lab Exam 1 MATLAB Solutions Name: Solution Section # Spring 2012 Problem 2 % Script 'Simple_Circuit.m' % Name, Section # % This script calculates the power and current in a simple electrical % circuit. It also uses logical variables to show which of a set of % resistors provides a current under 25 amps and at least 200 Watts of % power. % Step 1: R = [1.2 1.0 0.8 0.5 0.3]; % Ohms % Step 2: V = 12; % Volts I = V./R; % Amps % Step 3: P = I.^2.*R; % Watts % Step 4: less_25_amps = I < 25 more_200_watts = P >= 200 % Step 5: less_25_amps_and_more_200_watts = less_25_amps & more_200_watts Command Window Output >> run Simple_Circuit less_25_amps = 1 1 1 1 0 more_200_watts = 0 0 0 1 1 less_25_amps_and_more_200_watts = 0 0 0 1 0

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Problem 3 function [P_ave, P_max] = Car_Pressure (x)
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % Name, Section # % This function finds the relative pressure on the front of a car vertically % across the grill. % Inputs: x - vector of vertical positions (inches) % Outputs: P_ave - average pressure (PSI) % P_max - maximum pressure (PSI) % Step 1: P = 0.6*sin(x-10)-0.08*(x-10).^2+0.25*(x-10)+15; % PSI % Step 2: P_ave = mean(P); % PSI % Step 3: P_max = max(P); % PSI % Step 4: plot(x,P) title( 'Pressure vs. Position' ) xlabel( 'Position Along Front of Vehicle (inches)' ) ylabel( 'Pressure (PSI)' ) grid on Command Window Output >> x = 0:30; % inches >> [P_ave, P_max] = Car_Pressure (x) P_ave = 7.842 P_max = 15.726 5 10 15 20 25 30-15-10-5 5 10 15 20 Pressure vs. Position Position Along Front of Vehicle (inches) Pressure (PSI)...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern