0% found this document useful (0 votes)
5 views

practiceProblems1

The document outlines practice problems for a MATLAB programming course focused on numerical computations. It includes tasks related to array operations, converting scripts to functions, and plotting techniques. Specific exercises involve calculating exponential values, creating a function for steam pressure, and customizing plots for better visualization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

practiceProblems1

The document outlines practice problems for a MATLAB programming course focused on numerical computations. It includes tasks related to array operations, converting scripts to functions, and plotting techniques. Specific exercises involve calculating exponential values, creating a function for steam pressure, and customizing plots for better visualization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

MATLAB Programming for Numerical Computations Jan–March 2016

Module–1: Practice Problems


Week-1: 18th to 24th January

1. PRACTICE PROBLEM ON ARRAY OPERATIONS

We want to compute : &E.)G using MacLaurin series expansion. We have obtained a vector
terms = 0.25.^[1:n]./cumprod(1:n);
Explain what this vector contains. Use value of n = 6.
Use this vector to calculate the exponential. Note that the exponential is calculated as:
expVal = 1–terms(1)+terms(2)–terms(3)... so on until nth term.
Perform this in two ways: (i) using for loop; and (ii) without using any loops.

2. SCRIPT à FUNCTION

A simple but approximate formula for calculating pressure of saturated steam at any
temperature is given by: HI;J = K/100 L , where T is in degree C. Consider the script given
below that calculates saturation pressure given steam temperature (in K):
% Calculate pSat for steam
T = 400;
Tr = (400 – 273)/100;
pSat = Tr^4;
Convert the above script into a function that takes temperature in Kelvins as an input and
returns saturation pressure as output. From the command prompt, call this function as:
steamPressure(398) and steampressure(473).
The results should be 2.44 bar and 16 bar, respectively.

3. PLOTTING

Define vector t = [0:0.1:4];. Define vertical location of the ball using equation
, - = ./ - − 0.5 4- ) . This was done in Solved Problem #14 above. We now have a twist!
The command plot(t,y,'-bo') gives blue line with data-points shown as open
circles. Since the data is closely spaced, this does not look good.
Instead, plot the same graph such that the blue line is as before, but the circles are shown
only at 0.5 seconds interval (i.e., line goes through all 41 points, but symbols for 9 points only).
Hint: You will have to plot the same data twice: using '-b' to plot the line, and using 'bo'
to plot the symbols only.

You might also like