This is for MATLAB% Section 1 clear variables; close all; clc; % Use the \"Run S
ID: 3747158 • Letter: T
Question
This is for MATLAB% 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
Explanation / Answer
% 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) A * b % Calculate the product of inverse(A) x B in the space below (10 points) inv(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 clear variables; close all; clc; % 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(x, y, 'bo', x, z, 'r^') xlabel('Angle (Radians)') ylabel('sin(x) and x sin(x)') legend('sin(x)','x sin(x)') hold off
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.