Question
please do a-f, this is matlab
will rate
3. Generate a matrix A by setting A floor (10+rand(6)); and generate a vector b by setting b = floor (20*rand (6,1))-10; (a) Since A was generated randomly, we would expect it to be nonsingular. The system Axb should have a unique solution. Find the solution using the "operation (if MATLAB gives a warning about the matrix being close to singular, generate the matrix A again) (b) Enter U-rref ([A, b]) to compute the reduced row echelon form, U, of the augmented matrix CA b] Note that, in exact arithmetic, the last column of U and the solution x from part (a) should be the same since they are both solutions to the system Ax b. 2016 Stefania Tracogna, SoMSS, ASU MATLAB sessions: Laboratory 2 (c) To compare the solutions from part (a) and part (b), compute the difference between the last column of U and the vector x or examine both vectors U(:,7) and x using format long (when you are done, type format short to go back to the original format) (d) Let us now change A so as to make it singular. Set A(:,3)-4 AC,1)+5*A:,2) (the above command replaces the third column of A with a linear combination of the first two: a 4a 5a2 where a is the ith column of A.) Use MATLAB to compute rref (LA b]). How many solutions will the system Ax b have? Explain Hint: Look at the last row(s) of the RREF (e) Generate two vectors, y and c by setting floor (20*rand(6,1)) A*y; 10; = - y c = (here A is the matrix from part (d)) The way the vector c is defined guarantees that the system Ax = c is consistent, that is, it has at least one solution. Explain why that is the case. (f) Compute the reduced row echelon form U of [A c]. How many solutions does the systenm Ax=c have? Explain. Hint: Look at the last row(s) of the RREF
Explanation / Answer
%%% Matlab code %%%%
clc;
clear all;
close all;
A=floor(10*rand(6));
b=floor(20*rand(6,1))-10;
%%% a)
x=A;
%%% b)
U=rref([A b]);
%%% c)
format long
err=U(:,7)-x;
format short
%%% d)
A(:,3)=4*A(:,1)+5*A(:,2);
u1=rref([A b]);
disp('No solution in last row of u');