EGR_102_Lab_Exam_1_-_MATLAB_Solutions_-_

EGR_102_Lab_Exam_1_-_MATLAB_Solutions_-_ - % Name, Section...

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Problem 3 function [P_ave, P_max] = Car_Pressure (x)
Background image of page 2
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

This note was uploaded on 04/02/2012 for the course EGR 100 taught by Professor Hinds during the Fall '08 term at Michigan State University.

Page1 / 2

EGR_102_Lab_Exam_1_-_MATLAB_Solutions_-_ - % Name, Section...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online