Use MATLAB to solve following problems. You will be submitting published script.
ID: 3865205 • Letter: U
Question
Use MATLAB to solve following problems. You will be submitting published script. Be sure to comment your code. 10 points will be allocated for formatting. Be sure to do all problems in a single script except for plotting questions. Separate problems using "section" function in script. Be sure to include heading. Be sure to use MATLAB's "publish" function and print the output. Given: A=[-1 2 3 4 -5 6 7 8 -9] b=[-1 2 -3] c=[-9 8 7 6 -5 4 3 2 -1] a) Calculate: the determinant of A b) Calculate: A^-1 (C^T + A^2)b c) Calculate the eigenvalues and eigenvectors of A d) Solve the linear system: Ax = bExplanation / Answer
% Here I am giving script in matlab to solve the questions by dividing into sections and giving headings and also giving the way to use publish function to print output in html format %
%creating matrices A,b, C
A = [-1 4 7; 2 -5 8; 3 6 -9];
b = [-1; 2; -3] ;
C = [-9 6 3; 8 -5 2; 7 4 -1];
% To divide into sections we must follow the steps
In the EDIT section of matlab, go to comment button group. in that select icon with + symbol. enter two % symbols at start of line where you want to start section and then followed by heading %
%% obtaining determinant of A %This creating one section named as obtaining determinant of A
d = det(A); %finding determinant of A
disp('the determinant of matrix A is');
disp(d); % printing determinant value
%% calculating A-1 (CT + A2) b %This creating section named as calculating A-1 (CT + A2) b
y = inv(A); % finding inverse of matrix
x = A*A ; %finding square of A
z = transpose(C); %finding transpose of C
h = (z + x); %finding (CT + A2)
r = y*h*b ; %finding the result
disp('The result of product is');
disp(r); %displaying result
%% calculating eigen vectors and eigen values of A
%This creating section named as calculating eigen vectors and eigen values of A
[R,E,L] = eig(A); % finding eigen values E which is diagonal matrix, R right eigen vectors,L left eigen vectors
disp('the eigen vectors and eigen values are');
disp(R); %displaying right eigen vectors
disp(E); %displaying eigen values
disp(L); %displaying left eigen vectors
%% solving linear equation Ax = b %This creating section named as solving linear equation Ax = b
% we can solve linear equation in two ways one is using linsolve and using solve functions. but here it is better to %use linsolve
x = linsolve(A,b); %solving the equation
disp('The solutions of linear equation are');
disp(x); %displaying the result
% after creating this code, save the file with .m extension ex: myfile.m
then again open matlab, in that use publish function to get html file to view that matlab script in heml format
publish(file_name) ex: publish(myfile.m)
it will creat html subfolder in the script file folder. in that html/myfile.html is our html format of our matlab script. %
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.