Presentation is loading. Please wait.

Presentation is loading. Please wait.

MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.

Similar presentations


Presentation on theme: "MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne."— Presentation transcript:

1 MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne

2 206_M22 Course Outline  MATLAB IntroCh 1 MATLAB EnvironmentCh 2 Predefined FunctionsCh 3 PlottingCh 4 ProgrammingCh 5 Control StructuresCh 5 Matrix ComputationsCh 6 Test #3 Test #4

3 206_M23 Computer Software  Operating System Interface between user and hardware  Application Software Word Processors, Spreadsheets, Databases,... Computer-aided Design (CAD) Mathematical Computation Tools (MATLAB)  Computer Languages Machine Language Assembly Language High-level Languages (C++)

4 206_M24 Problem-Solving  An Engineering Problem-Solving Methodology Problem Statement Input/Output Description Hand Example Algorithm Development Testing

5 206_M25 Example  Temperature Analysis Problem Statement Compute the average of a set of temperatures, then plot the time and temperature values. Input/Output Description Time Values Temperature Values Average Temperature Plot of Time and Temperature Values

6 206_M26 Example Hand Example Average = (105 +126 +119)/3 = 116.67 Degrees F Algorithm Development (outline) Input times and temperatures Compute average Plot times and temperatures Time (Minutes)Temperature (Degrees F) 0.0105 0.5126 1.0119

7 206_M27 Example MATLAB Solution % Compute average temperature and % plot the temperature data. % time = [0.0, 0.5, 1.0]; temps = [105, 126, 119]; average = mean(temps) plot(time, temps), title('Temperature Measurements'), xlabel('Time, minutes'), ylabel('Temperature, degrees F'), grid

8 206_M28 Example Testing

9 206_M29 Example

10 206_M210 Example Testing time = [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0,... 3,5, 4.0, 4.5, 5.0]; temps = [105, 126, 119, 129, 132, 128, 131,... 135, 136, 132, 137];

11 206_M211 Example

12 206_M212 MATLAB Windows

13 206_M213 MATLAB Windows  Current Directory Window  Command Window  Command History  Workspace Window  Document Window Array Editor  Graphics Window  Editor Window  Start Button

14 206_M214 Scalar Operations Exponentiation ^ Multiplication * Division / Addition + Subtraction - Precedence 2 3 4

15 206_M215 Expressions num = x^3 - 2*x^2 + x - 6.3; den = x^2 + 0.05*x - 3.14; f = num/den;

16 206_M216 Arrays, Vectors and Matrices  Row Vector X = [1 2 3 4]; (1x4)  Column Vector Y = [1; 2; 3; 4]; (4x1) Y = [1 2 3 4]'; transpose operator  Matrix A = [1 2; 3 4; 5 6]; (3x2)  Evenly Spaced Matrices B = [1:5]; C = [1:2:5]; D = linspace(1,10,3);

17 206_M217 Array Operations  Arrays with Scalars Same  Arrays with Arrays Same for Addition and Subtraction  Element-by-Element Operations Exponentiation.^ Multiplication.* Division./

18 206_M218 Number Display  Scientific Notation LightSpeed = 2.99792e08;  Display Format format long format long e format short format short e format bank format +

19 206_M219 Saving Your Work  Saving Variables Save the contents of the Workspace Window to a file Default format binary.mat save load ASCII (text).dat save -ascii load  Script M-Files ASCII (text).m MATLAB Editor Window % This is a comment

20 206_M220 Problem Solving Applied  UDF Engine Performance Problem Statement Calculate the velocity and acceleration using a script M-file Input/Output Description Velocity Start Time = 0 sec Acceleration Final Time = 120 sec Time Increment = 10 sec

21 206_M221 Problem Solving Applied Hand Example velocity = 0.00001 time 3 - 0.00488 time 2 + 0.75795 time + 181.3566 acceleration = 3 - 0.000062 velocity 2 For time = 100 sec  velocity = 218.35 m/sec  acceleration = 0.04404 m/sec 2 Algorithm Development (outline) Define time matrix Calculate velocity and acceleration Output results in table

22 206_M222 MATLAB Solution clear, clc %Example 2.4 %These commands generate velocity and acceleration %values for a UDF aircraft test %Define the time matrix time = 0:10:120; %Calculate the velocity matrix velocity = 0.00001*time.^3 - 0.00488*time.^2... + 0.75795*time + 181.3566; %Use calculated velocities to find the acceleration acceleration = 3 - 6.2e-5*velocity.^2; %Present the results in a table [time', velocity', acceleration']

23 206_M223 Testing

24 206_M224 Summary  MATLAB Environment  Scalar Operations  Array Operations  Saving Your Work  End of Chapter Summary MATLAB Summary Characters, Commands and Functions Key Terms


Download ppt "MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne."

Similar presentations


Ads by Google