Would you please solve this Matlab practice assignment, all I need are very simp
ID: 3571492 • Letter: W
Question
Would you please solve this Matlab practice assignment, all I need are very simple imputs. Thank you for your help, Chegg has been incredibly invalueable this semester.
1. (2 pts) Initialize the following variables: a 2, b 9, c 0.3 2. (2 pts) write the following equation in Matlab code d m 5c a b (a-c) 3. (2 pts Initialize a vector called num2 with values 169 64 121, and 192. 4. (2 pts) Find the square root of the variable num2 by using the square-root function. 5. (2 pts) Multiply num2 by 3, and then subtract 100 6. (2 pts) create the variable theta with the value 25 (which is in degrees), then use the function for cosine that accepts values in degrees (not radians) 7. (3 pts) create the variable the ta2 with the value 1.2 (which is in radians), then use the function for sine that accepts values in radians (not degrees) 8. (2 pts) create a variable that is a complex number where the real component is 8 and the imaginary component is 2 9. (3 pts) create one vector called vec with the values of 2, 4, 6, and 8. Then create another vector called vec2 with the values 2.3, 3.7, 8. 1, and -4.99Explanation / Answer
close all
clear all
clc
%1
a = 2;
b = 9;
c = 0.3;
%2
d = (5 * c) + (a * a) - (b * (a - c))
%3
num2 = [169 64 121 192]
%4
num2_sqrt = num2.^0.5
%5
num2_x_3 = num2.* 3;
num2_sub_100 = num2_x_3 - 100
%6
theta = 25
cos_value = cos((pi * 25) /180)
%7
theta2 = 1.2
sin_1_2 = sin(1.2)
%8
comp_var = -8 + 2i
%9
vec = [2 4 6 8]
vec2 = [2.3 3.7 -8.1 -4.99]
%10
vec_x_vec2 = vec.*vec2
%11
vec2_abs = abs(vec2)
%12
vec2_sqrt = sqrt(vec2)
%13
vec_power_3 = vec.^3
%14
vecA = [ 2 3 4 5 6 7 8 2.6 3.6 4.2]
%15
vecB = [0.5:0.5:5]
%16
vecA_x_vecB = vecA.*vecB
%17
vecAt = vecA'
vecBt = vecB'
%18
a = [15 3 22;3 8 5;14 3 82]
b = [1 5 6]'
c = [12 18 5 2]
%18 a)
d = a(:,3)
%18b
e = horzcat(b,d)
%18c
f = vertcat(b,d)
%18d
g = vertcat(a,c(:,1:3))
%18 e
h = [a(1,3) c(1,2) b(2,1)]
%19 a
M = magic(6)
sum(M)
%19b
sum(M')
%19c
sum(diag(M))
%20
Area = zeros(5,11);
i = 1;
j = 1;
for k = 2:6
j=1;
for l = 0:10
Area(i,j) = k * l;
j = j + 1;
end
i = i + 1;
end
Area
% 21 a
x = 0:0.5:10
y = exp(x);
figure(1)
plot(y,x)
title('Exponential plot y = e^x')
xlabel('x');
ylabel('y');
%21 b
y = sin(x);
figure(2)
plot(x,y)
title('Sin wave y = sin(x)')
xlabel('x');
ylabel('y');
%21 c
y = 5.*x.*x + 2.*x + 4;
figure(3)
plot(y,x)
title('quadratic equation plot y = 5x^2 + 2x + 4')
xlabel('x');
ylabel('y');
%21 d
y = sqrt(x);
figure(4)
plot(y,x)
title('quadratic equation plot y = sqrt(x)')
xlabel('x');
ylabel('y');
%22
x = -pi:0.01:pi;
y1 = sin(x);
y2 = sin(2.* x);
y3 = sin(3.* x);
figure(5);
plot(x,y1,'color','r');
hold on
plot(x,y2,'color','b');
hold on
plot(x,y3,'color','g');
hold off
title('Plot for sin')
xlabel('time')
ylabel('amplitude')
legend('sin(x)','sin(2x)','sin(3x)');
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.