In: Computer Science
MATLAB QUESTION
HOW TO FOLLOW TO EACH STEPS PLEASE GIVE TO EXPLAIN EACH SECTION
THANKS!
% Section 1
clear variables;
close all;
clc;
% Use the "Run Section" button as you complete this script
% Given the matrix A and the vector B
A = [ 1 -4 2
-2 3 3
5 2 1];
b = [ -2
3
5];
% Calculate the product of A x B in the space below (grade = 10 points)
% Calculate the product of inverse(A) x B in the space below (10
points)
% Calculate c = the numeric value in the second row and
% first column of matrix [A] in the space below (10 points)
%% Section 2
clear variables;
close all;
clc;
% Create a variable x = range of 10 numbers
% between -pi and pi (radians) (grade = 10 points)
% Set y = sin(x) in the space below (10 points)
% Set z = x * sin(x) in the space below (10 points)
% HINT: You will need the .* for this operation instead of *
% Plot y and z versus x between the "hold on" and "hold off"
commands
% Label the x and y axes properly and use appropriate units (10
points)
% use xlabel('Angle (Radians)')
% use ylabel('sin(x) and x sin(x)')
% Plot y using a blue line with circular markers (10 points)
% On the same plot, include z using a red line with triangular
margers
% (1 point)
% use legend('sin(x)','x sin(x)') (10 points)
hold on
hold off
% After completing your script, click the "PUBLISH" tab
% Click the button in the "PUBLISH" tab, which is labeled
Publish
SECTION 1
% Given the matrix A and the vector B
A = [ 1 -4 2
-2 3 3
5 2 1];
B = [ -2
3
5];
% Calculate the product of A x B in the space below (grade = 10
points)
A * B
% Calculate the product of inverse(A) x B in the space below (10
points)
inverse(A) * B
% Calculate c = the numeric value in the second row and
% first column of matrix [A] in the space below (10 points)
c = A(2, 1)
SECTION 2
% Create a variable x = range of 10 numbers
% between -pi and pi (radians) (grade = 10 points)
x = linspace(-pi, pi, 10);
% Set y = sin(x) in the space below (10 points)
y = sin(x);
% Set z = x * sin(x) in the space below (10 points)
% HINT: You will need the .* for this operation instead of *
z = x.*sin(x);
% Plot y and z versus x between the "hold on" and "hold off"
commands
% Label the x and y axes properly and use appropriate units (10
points)
% use xlabel('Angle (Radians)')
% use ylabel('sin(x) and x sin(x)')
% Plot y using a blue line with circular markers (10 points)
% On the same plot, include z using a red line with triangular
margers
% (1 point)
% use legend('sin(x)','x sin(x)') (10 points)
hold on
plot(y, x, 'b--o', z, x, 'r--^');
xlabel('Angle (Radians)')
ylabel('sin(x) and x sin(x)')
print -dpng graph.png;
hold off
% After completing your script, click the "PUBLISH" tab
% Click the button in the "PUBLISH" tab, which is labeled
Publish