Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 1: Write MATLAB code to create a 5x5 matrix A with 2's on the diagonal, and -1 on the super- and sub-diagonal. Then replace

image text in transcribed

Exercise 1: Write MATLAB code to create a 5x5 matrix A with 2's on the diagonal, and -1 on the super- and sub-diagonal. Then replace the (1,1) element of A with a 1. (Make your commands capable of handling an arbitary sized NxN matrix by first defining N=5, then using the variable N as the size in each of the commands.) % Put your code here Exercise 2: Write MATLAB code to create an N dimensional vector t with uniformly spaced numbers between 0 and Then create a vector y with the data f(t) where f(t) = 6 sin(t) - 9 sin(t). Finally, multiply each entry of y by h, where h= 2(N+1) % Put your code here Exercise 3: Find the inverse of the matrix A. Describe the pattern that you see in the entries. % Put your code here Put your observations here Exercise 4: Solve the system of equations Ax = y two different ways, first by multiplying y by the inverse of A (you may need to transpose y for the dimensions to be compatible), and second by using the backslash operator. Compare the two solutions by plotting each vs t on the same graph. (Note: if you use hold on, be sure to put hold off at the end.) % Put your code here Exercise 5: Repeat all of the above exercises but with N=10, N=50 and then N=500. (Either copy/paste all the commands here, or simply change N above and re-execute the sections.) What do you notice as you increase N? This code is actually an implementation of a finite difference approximation to the solution of a second order ordinary differential equation boundary value problem. Check that the approximation matches the true solution, 1-sin^3(t), by plotting each vst on the same graph. % Put your code here

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

Genetic Databases

Authors: Martin J. Bishop

1st Edition

0121016250, 978-0121016258

More Books

Students also viewed these Databases questions