#### Question Details

[answered] MATH241 MATLAB Homework No submissions over mail, hardcopy

Hello. I have a matlab assignment due 12.12.2016. All details are in the attachment.

MATH241 MATLAB Homework

No submissions over mail, hardcopy only Q1.

In modeling the equilibrium temperature distribution in a metal rod, one may use the differential equation:

?2 ?? 2 ? ? ?=

?? ? , 0???1 where ? is the spatial location in the rod,? (? is an externally-applied heat source, and ? ? is the

)

temperature throughout the rod. A simple approximation

of this equation uses the formula

?2

?? 2 ? ? ? ? ?+? ?2? ? +? ???

?2 1 where ? = ??1. , Suppose the ends of the rod are held at a fixed temperature of 5, i.e. ? 0 = 5 and ? 1 = 5, and that

heat is applied evenly along the length of the rod, ? ? = 2.

If we store the solution values at ?locations in the rod, ?? = ? ? 1 ?, then these temperatures ?? ?

? ?? may be stored in a vector, ? = [?1, ?2, ? . ,???, and this vector solves a linear system of

equations ?? = ?,

1 = 5, ? ? 1

2

1

?1 + 2 ?2 ? 2 ?3 = 2

2

?

?

? ? 1

2

1

?2 + 2 ?3 ? 2 ?4 = 2

2

?

?

?

? ? 1

2

1

???2 + 2 ???1 ? 2 ?? = 2

2

?

?

?

? = 5. ? You may implement this in Matlab following few simple commands:

>>

>>

>>

>>

>>

>> N = 201;

h = 1/(N-1);

A = zeros(N,N);

A(1,1) = 1;

A(N,N) = 1;

for i=2:N-1

A(i,i-1) = -1/(h^2);

A(i,i) = 2/(h^2);

A(i,i+1) = -1/(h^2);

end

>> b = 2*ones(N,1);

>> b(1) = 5;

>> b(N) = 5; Perform the following tasks:

(a) Use the above commands to create the matrix A and right-hand side vector b.

(Do not print the matrix A and vector b in your report)

(b) Explore the function ? ? ? ( ) in MATLAB and use it to find the reduced row echelon form of

?

matrix ?.

(c) based on part b) show that the columns of matrix ? are linearly independent and hence the matrix

is invertible. Justify

(d) Without inverting ? find the reduced row echelon form of an augmented matrix [? ?]

(e) from d) find a unique solution to the problem ?u = ?

(f) Plot your result using the Matlab command plot(u)

(g) Check that Nul(A) contains only the zero vector by finding its basis with the command null(A). We now change the boundary conditions of the rod, so that instead of holding the temperature fixed, we

now insulate both ends from the environment; mathematically represented by ?

? 0 = 0,

?? ?

? 1 = 0

?? We may approximate these in our linear system by replacing our first and last equations with 2

2

?

?

? =2

1

?2

?2 2

? 2

2

?

+

? =2

??1

?2

?2 ? Perform the following tasks:

(h) Modify the first and last rows of your matrix? and right-hand side vector b to implement these

two equations.

(i) Try to solve for the temperature, by introducing new matrix ? =

[ ????([? ?]).Show that system of

linear equations ?? = ? becomes inconsistent. You may try as usual, ?\? in command window to

observe if the matrix is invertible or not.

(j) Determine a basis for Nul(A) for this new matrix ?.

(k) By looking at your basis from part (j), in a sentence or two, try to explain the physical meaning of

Nul(A) for this problem. Q2.

In the accompanying file, climate_data.txt, the average global temperature (in degrees Fahrenheit) is

provided for the years 1880 through 2015 [from NOAA.gov]. The first column of data contains the

number of years since 1880 (i.e. ?10? would be the year 1890), and the second column contains the

average global temperature for that year. As with any natural phenomena, these temperatures consist of

underlying trends overlaid with random fluctuations. We will use least-squares in an attempt to extract

these underlying trends.

Following MATLAB code constructs the best cubic polynomial fit to the data, use it to plot both the data

and resulting predictions from 1880 through 2025. The code is commented to better explain the process:

>> load climate_data.txt % load data into MATLAB

>> years = climate_data(:,1); % extract 1st column as "years" vector

>> temps = climate_data(:,2); % extract 2nd column as "temps" vector

% build the matrix and solve the least-squares system.

% Note: the .^ notation raises each entry to the requested power

>> A = [years.^3, years.^2, years.^1, years.^0]; % construct A

>> b = temps; % build the right-hand side

>> x = (A'*A) \ (A'*b); % solve the least-squares problem

% set the dates that we want to plot over (offset by 1880)

>> dates = linspace(0,145,200);

% compute the projections based on the model

>> proj = x(1)*dates.^3 + x(2)*dates.^2 + x(3)*dates.^1 + x(4)*dates.^0;

% plot the data as black dots and the model as a blue line

>> plot(years+1880,temps,'k.',dates+1880,proj,'b-')

>> xlabel('year')

>> ylabel('temperature')

>> title('Climate data and cubic fit') Note here that our cubic polynomial has the form

?(? ) = 1?3 + ?2?2 + 3?? + 4?

?

so the matrix in our over determined linear system has the form ?= 3

?

?12 ?1

1

?

?23 ?22 ?2

? ? ?

3

??

??2 ?? 1

1=

?

1 ?13 ?12 ?11 ?10

?23 ?22 ?21 ?20

? ? ? ?

??3 ??2 ??1 ??0 Since years is a column vector with the values [?1 ?2 . . ?.? ]? , this is why we can construct the full matrix

? in Matlab with the one line command A = [years.^3, years.^2, years.^1, years.^0] Perform the above commands. Repeat the process for both a quadratic model and a linear model.

For these models, you should only need to modify the lines

A = [years.^3, years.^2, years.^1, years.^0]; and

proj = x(1)*dates.^3 + x(2)*dates.^2 + x(3)*dates.^1 + x(4)*dates.^0; and

title('Climate data and cubic fit') Turn in printouts of your three plots for question 2 only. DO NOT print matrices A and b for either questions 1 and 2!!

**Solution details:**

Answered

QUALITY

Approved

ANSWER RATING

This question was answered on: * Sep 18, 2020 *

* * Solution~0001013688.zip (25.37 KB)

This attachment is locked

We have a ready expert answer for this paper which you can use for in-depth understanding, research editing or paraphrasing. You can buy it or order for a fresh, original and plagiarism-free copy from our tutoring website www.aceyourhomework.com (Deadline assured. Flexible pricing. TurnItIn Report provided)

##### Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .

#### About this Question

STATUSAnswered

QUALITYApproved

DATE ANSWEREDSep 18, 2020

EXPERTTutor

ANSWER RATING

#### GET INSTANT HELP/h4>

We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.

You can also use these solutions:

- As a reference for in-depth understanding of the subject.
- As a source of ideas / reasoning for your own research (if properly referenced)
- For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).

#### NEW ASSIGNMENT HELP?

### Order New Solution. Quick Turnaround

Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions.
New orders are original solutions *and precise to your writing instruction requirements. Place a New Order using the button below.*

WE GUARANTEE, THAT YOUR PAPER WILL BE WRITTEN FROM SCRATCH AND WITHIN YOUR SET DEADLINE.