## ENGG1811 Lab 12: Linear Equations and 3D Plots

• The online assessment (the last for the semester) is on curve fitting.
• Part A (Solving Linear Equations) is worth one mark.
• Part B (3D plots of experimental data) will not be assessed and you can do it in your own time.

### Part A: Solving Linear Equations

A separation process accepts a mixture of water, ethanol and methanol in certain proportions, and produces two output streams, each with particular proportions of the component liquids. The input flow of the combined liquids is 100 L/min, and the output flows are the unknowns b and c. The proportions in each stream are shown in the yellow boxes.The output proportions are known, as is the input proportion of water. The proportion of ethanol in the input stream is the third unknown x.

Since the input and output flow of each material must match, we can devise three equations in the three unknowns: 1. Re-arrange these equations so that each is of the form
z1 x + z2 b + z3 c = k
where the z coefficients and k are constants.
2. Express the solution in matrix form A x = b, where
A is the matrix of coefficients,
x is the column vector of unknowns and
b is the column vector of right-hand-side constants.
3. Write a Matlab script (so you can recall how you solved the problem later) that assigns the matrix A and vector b, using multiple lines continued with ... to align the columns of A neatly. Remember that b is a column vector.

Then solve the equations using matrix left division:

```x = A \ b
```
4. Interpret the results. Confirm that x is no greater than 0.5 (otherwise the methanol input proportion would be negative). What do you expect the sum b + c to be? (Think about overall flows if this isn't clear.)

### Part B: 3D plots of experimental data

You have worked on the Sea Ice Index data set in Week 11's lab. You are going to use this data set again but this time you are going to use 3D plots to visualise the data.

Among the many data sets used in climate change research, the Sea Ice Index, or the area covered by sea ice in the northern hemisphere shows particularly marked changes.There are normal variations across each year, and trends over the span of years. We can treat these two as x and y variables, and the sea ice extent as the dependent z variable in a 3D plot.

The file NHsea_ice_extents.txt contains monthly northern hemisphere total sea ice data between 1979 and 2013.Each row starts with the year, then has two area samples each month in units of millions of square km.

It doesn't need much processing to display this data effectively. Download the data file, place it in a folder on Matlab's path. Follow these steps, try to understand what each is doing from the comments. Paste the non-comment lines one at a time, not all at once! Matlab's response is not shown.

Note that the pre-processing steps are the same as what you did last week, you can cut and paste that block of commands if you wish. The pre-processing steps are enclosed between "% BEGIN: Pre-processing" and "% END: Pre-processing".

```% BEGIN: Pre-processingload NHsea_ice_extents.txt
% the data is tab-separated, load assigns it to a variable named after the file

size(NHsea_ice_extents)
% rows = number of years, columns = number of elements in a year

% what's in the first row?
NHsea_ice_extents(1,:)

% the first column has the year, the rest is area data. We need to move the years
% into a different variable
years = NHsea_ice_extents(:,1);   % first column, easy
NHsea_ice_extents(:,1) = [];      % remove the first column by assigning nothing
size(NHsea_ice_extents)           % should be 35 (years) x 24 (half-monthly samples)

% the month range should be 1 to 12 as usual, but we have 24 samples:
months = linspace(1,12,24);
% END: Pre-processing% BEGIN: Plotting % the months and years vectors are ready to be converted to 3D grid matrices
[mG, yG] = meshgrid(months, years);    % G for grid
size(mG), size(yG)

% plotting time
surf(mG, yG, NHsea_ice_extents)

% default shading is faceted, flat is OK but interp is definitely the best for this data

% autoscaling the axes is sometimes a bit off, we know better what they should be
axis([1 12.99 1975 2015 0 20])

% finally we associate red with both danger and heat, and blue with cold,
% the default colouring (stored in a special variable colormap, an Nx3 matrix
% of RGB values) is opposite to what makes sense to us. flipud inverts rows (up-down).
colormap(flipud(colormap))

```
Now add a title, and x, y and z labels.
Then use the 3D rotate icon to examine this rich data set. You should be able to show your tutor the overall trend side view,the "end elevation view" and any other one they ask for. Which recent years does the data suggest were the worst for sea ice (we're looking for local dips in the low points)?