# Lab6

### Text-only Preview

Purdue University Calumet

Enginerning Department

ENGR 151

Software tools for engineers

LAB 6

Due date: Monday March 4, 2013

* Purpose: To visualize an equation and use a combination of FOR loop and IF-END

statement to find the solution to a simple engineering problem.

* Step 1: Create a new script file LASTNAME LAB6.m. Answer the following ques-

tions by writing in the script file

- Clear screen

- Clear workspace

- Display your name

- Display the text "Part 1"

- Generate 1000 random numbers from 4 to 7 and count up the number of elements

that are > 5 and < 6 and display the result using SPRINTF.

- Display the text "Part 2"

- Using what you have learned in the last several labs it is desired to first make a

plot of the following equation:

10

P = RL

RL + 20

The equation is derived from the circuit shown below:

1

Purdue University Calumet

Enginerning Department

The Y axis variable P is power of the resistor RL which is transferred from a

battery modeled as a voltage source VT h equal to 10 V also having and internal

heating loss modeled by RT h = 20 Ohms .

It is desired to plot the power P on the Y axis in terms of the load resistance

RL on the X axis for the purpose of estimating the value of RL which results in

a maximum value of P . Assume the input RL, changes from 0 to 40 Ohms with

a step size of 0.1 Ohms. Create the plot described above and add a title, the

appropriate x and y labels and lastly activate a grid to aid in reading the plot.

- Display the text "Part 3"

- Use a FOR loop starting at RL = 0 having an ohmic step size of 0.001 ohms to

find the value of RL which makes power P maximum. You will need to include

an appropriate IF statement in your code to determine when the maximum value

of P is reached and stop the FOR loop using the BREAK command. Lastly, use

a combination of the SPRINTF and DISP commands to print out the solution

found for the value of RL and the corresponding value of load power P.

Hint: You can use the plot to determine an approximate answer for comparison

purposes.

* Step 2: Upload the file LASTNAME LAB6.m to blackboard.

2

Enginerning Department

ENGR 151

Software tools for engineers

LAB 6

Due date: Monday March 4, 2013

* Purpose: To visualize an equation and use a combination of FOR loop and IF-END

statement to find the solution to a simple engineering problem.

* Step 1: Create a new script file LASTNAME LAB6.m. Answer the following ques-

tions by writing in the script file

- Clear screen

- Clear workspace

- Display your name

- Display the text "Part 1"

- Generate 1000 random numbers from 4 to 7 and count up the number of elements

that are > 5 and < 6 and display the result using SPRINTF.

- Display the text "Part 2"

- Using what you have learned in the last several labs it is desired to first make a

plot of the following equation:

10

P = RL

RL + 20

The equation is derived from the circuit shown below:

1

Purdue University Calumet

Enginerning Department

The Y axis variable P is power of the resistor RL which is transferred from a

battery modeled as a voltage source VT h equal to 10 V also having and internal

heating loss modeled by RT h = 20 Ohms .

It is desired to plot the power P on the Y axis in terms of the load resistance

RL on the X axis for the purpose of estimating the value of RL which results in

a maximum value of P . Assume the input RL, changes from 0 to 40 Ohms with

a step size of 0.1 Ohms. Create the plot described above and add a title, the

appropriate x and y labels and lastly activate a grid to aid in reading the plot.

- Display the text "Part 3"

- Use a FOR loop starting at RL = 0 having an ohmic step size of 0.001 ohms to

find the value of RL which makes power P maximum. You will need to include

an appropriate IF statement in your code to determine when the maximum value

of P is reached and stop the FOR loop using the BREAK command. Lastly, use

a combination of the SPRINTF and DISP commands to print out the solution

found for the value of RL and the corresponding value of load power P.

Hint: You can use the plot to determine an approximate answer for comparison

purposes.

* Step 2: Upload the file LASTNAME LAB6.m to blackboard.

2