Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part 5: In a Matlab script create two vectors as per following instruction: a. T

ID: 3881267 • Letter: P

Question

Part 5: In a Matlab script create two vectors as per following instruction: a. The first vector is a set of temperatures recorded in degrees Celsius. Create this vector using the "colon operator (:)" so that it goes from 0 to 100 degrees with a step size of S. It should be named Templ b. The second vector is a set of temperatures recorded in degrees Fahrenheit. Use linspace)" to create the vector with 21 elements ranging from 20 to 220. Name this vector Temp2 The second vector must be converted to degrees Celsius. Use the conversion c. On executing the script only Temp2C should be visible on the screen rest all the statements must be silenced Name the script file as Team#HW 3 ABPS Copy the code in function file as well as the inputs created, and outputs generated in the command window in the Word document under the heading Part 5. Clearly indicate the script file code and the inputs as well as the outputs from the command window Part 6: The relationship to calculate the pressure change, due to change in temperature, for a constant volume of an ideal gas is known as Gay-Lussac's Law and is given as: Write a function wherein, you will have 1 output ie, new pressure (P:) and 3 inputs i.e. initial pressure Pi and temperature Ti and T. The value of initial pressures P (in atm) is: P- [5, 10, 7, 12,2, 16,9] while, Ti and T: have 7 values ranging from 0 to 100 and 20 to 220, respectively. Create vectors Pt, Ti, and T in the command window using appropriate built-in functions available in Matlab for creating 1-D arrays In the function file, find the new pressures (P using Eq. [7]. Consider using dot operator in your pressure calculation. Make sure to include comments Execute the function from the command window using the Pi, Ti, and T: as an input to the function. On executing the function, only the final output i.e., P: should be visible in the command window Name the function as Team HW3AB P6

Explanation / Answer

If you post more than 1 question, as per chegg guidelines I have to solve only 1 question.

Part 5:

--------------------------------Temp2C.m----------------------------------------------

function Temp2C()

    % first vector to store degree celcius

    v1 = [ 0 : 5 : 100 ];

    % create second vector to store temperature in Ferhanheit

    v2 = linspace(20, 220, 21);

    fprintf('Part 5 ');

   

    fprintf('Input ... V1 : ');

    disp(v1);

    fprintf('V2 (In Farhenheit) : ');

    disp(v2)

   

    for i = 1 : length(v2)

        % convert degree celcius to degree Ferhanheit

        v2(i) = ( v2(i) - 32 * 5 / 9 );

    end

    fprintf('V2 (In Celsius) : ');

    disp(v2)

   

end

----------------------------------main.m-------------------------------

Temp2C();

Sample Output:

Part 5
Input ...
V1 : Columns 1 through 10

0 5 10 15 20 25 30 35 40 45

Columns 11 through 20

50 55 60 65 70 75 80 85 90 95

Column 21

100

V2 (In Farhenheit) : Columns 1 through 10

20 30 40 50 60 70 80 90 100 110

Columns 11 through 20

120 130 140 150 160 170 180 190 200 210

Column 21

220

V2 (In Celsius) : Columns 1 through 6

2.2222 12.2222 22.2222 32.2222 42.2222 52.2222

Columns 7 through 12

62.2222 72.2222 82.2222 92.2222 102.2222 112.2222

Columns 13 through 18

122.2222 132.2222 142.2222 152.2222 162.2222 172.2222

Columns 19 through 21

182.2222 192.2222 202.2222