Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please write the code in matlab. i provided syntax guide hope it helps thanks GOALS: Investigate various properties of plotting in MATLAB. PART A: The

image text in transcribedplease write the code in matlab. i provided syntax guide hope it helps thanks
image text in transcribed
image text in transcribed
image text in transcribed
GOALS: Investigate various properties of plotting in MATLAB. PART A: The following two equations describe the voltage (V) and power (P) as a function of Current (I) across a resistor (R): V = IR P=1?R Create a MATLAB program to plot these two equations on the same graph. The program should have the user input the resistance (Ohms) and maximum current (amps). The maximum current should be used to create a ID array of current values starting at zero and going to the maximum current Make sure your plot includes the following: Separate Y axes for the Voltage and the Power Different line colors and types for each variable plotted A title, axes labels, legend and grid Use the MATLAB help tools to investigate the various commands for plot annotation as well as the command used to setup a plot with two y-axes. When the program is complete, test it with the following input values: Resistance = 75 and Maximum Current = 6. When completed, copy and paste the plot into a Word document and save it as: HW5p2_Taskl_TEAMXXX_6+2.docx Save your script file with the following file name: HW5p2_Taski_TEAMXXX_6+2.m PART B: Using the same program file (HW5p2_Taskl_TEAMXXX_6+2.m) and values from Part A, include a second figure which includes a subplot with three rows and one column. The three plots shown should contain the following information: Subplot l: Voltage versus Current Subplot 2: Power versus Current Subplot 3: Voltage and Power versus Current on same plot (Same as Part A) When this part of the program is complete, run it using the previously entered values for Resistance and Maximum Current, then copy and paste the 3 x 1 subplot into the same word document from Part A: HW5p2_Taskl_TEAMXXX_6+2.doc Input Statements: 8 Prompt the user to enter a number X = input ("Enter a number please: '); % Prompt the user to enter a numerical array V = input('Enter your array values in square brackets: "); % Prompt the user to enter text (a string) month = input('Enter the month that you were born: ', 's'); % Create a pop-up menu with directions & three buttons: Yes, No, What? choice = menu('Do you enjoy programming', 'Yes', 'No', 'What?'); Output Statements: % Decimal Numbers X - 75.176; fprintf('The variable x = 80.2f n',x); % 80.2f means show two places behind decimal point The variable x = 75.18 8 Integers Y = 750; fprintf ("The value of y is: $i ',y); The value of y is: 750 % Strings course - 'Calculus II'; fprintf('The name of this course is: 8 ', course); The name of this course is: Calculus II % Mixture x = 75.176; Y = 750; course = 'Calculus II'; fprintf('x = 80.1f, y = $i, course is is ', x, y, course'); x = 75.2, y = 750, course is Calculus II v Subtraction Multiplication Division Power Modulo Not Equal Less Than Greater Than Less Than or Equal To Greater Than or Equal To Scalar Or Not Array And Array OR mod (a,b) >= % Strings month = 'July'; strcmp (month, 'July'); True strcmp (month, August'); 8 False strcmp (month, 'july'); $False (MATLAB is Case Sensitive!) Conditional Statements: if Conditioni $ MATLAB Commands to execute if Conditionl is TRUE elseif Condition2 % MATLAB Commands to execute if Conditioni is FALSE % and Condition 2 is TRUE elseif Condition3 8 MATLAB Commands to execute if Conditionl is FALSE 8 and Condition is FALSE and Condition3 is TRUE else MATLAB Commands to execute if Conditions 1-3 are FALSE end For loops: Assume variable Nis defined as an integer for k= 1:N MATLAB Commands to execute a total of N times Counter index, k, starts at 1 and increments to N end Another Option fork - 1:3:12 8 MATLAB Commands # Counter index, k, loops through the values 1, 4, 7, 10 end While Loops: while Condition % MATLAB Commands will execute again and again as long as % Condition is true end Arrays: Note: in MATLAB, the first entry in an array is indexed as 1. This is different from Python where the first entry in a list or array is indexed as O! Suppose x is a vector (1-d Array) x (1) 815entry of vector x x(2:4) 8200 ; 3rd, and oth entries of vector x x (3) - 5 Puts a 5 in the 3rd entry of vector x N = length(x) 8N - the number of entries in vector x Suppose M is a matrix (2-d Array) M(1,4) is the entry in the 1st row and 4th column of M M(2,3) - 5 Puts a 5 in 2nd row and 3 column of M [Rows Cols) - size (M) Rows = number of rows in M Cols - number of columns in M

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions