Question
need help in my mathlab HW please
Create an array by assigning theta from o to 5pi/4 with a step size of pi/4, and assign radius, r=2. (use linespace) theta = 0: Now using the equations x = r * cos (theta) and y = r * sin (theta) compute the values of the two variables using the r=2 and the array of theta. Note show that r = is ture by taking your times and y answers putting them through the r= equation you just created him. (Hint: all of your answers should be 2) Use line space to create a vector t form 1 to 10 with 91 elements and define the function: y = (Remember to use the; to suppress the output and use help if you need to remember what line space is) Plot the function y in black and include a title with the expression for y make the same plot as in part a, but rather than displaying the graph as a curve show the unconnected data points. To display the data with small circles, use plot(t, y,'o'). Now combine the two points with the command plot (t, y,0-') to show the line through the data points. Create a circular helicx by assigning x=sin(t), y=cos() and z=t with 0 20 (use t= linspace() and plot3() to get the graph. (help plot3) Simple matricx calculations just so you know how to use them. First enter in these matrices A= [153 426 289], B= [147 258 369 ], b= [4 23 27] , c+ [4 3 2 } ; d= [123] Preform the following operations: AB, BA, cB,and ad Construct a 3times 6matrix C=[A B] and a 4Time3 D = [3c]. Solve for Ax=by using the backslash command Transpose the vectors b and c (remember the ')
Explanation / Answer
close all
clear all
clc
%% 1
theta = linspace(0,5*pi/4,6);
r = 2;
%% a
x = r*cos(theta);
y = r*sin(theta);
%% b
R = sqrt(x.^2+y.^2);
fprintf('1(b). r ');
disp(R);
%% 2
t = linspace(1,10,91);
y = (exp(t/10).*sin(t))./(t.^2+1);
%% a
plot(t,y,'k');
title('e^(t/10)*sin(t)/(t^2+1)')
%% b
figure
plot(t,y,'o');
%%
figure
plot(t,y,'o-');
%% 3
t = linspace(1,20);
x = sin(t);
y = cos(t);
z = t;
figure
plot3(x,y,z);
%% 4
A = [1 4 2; 5 2 8; 3 6 9];
B = [1 2 3; 4 5 6; 7 8 9];
b = [4; 23; 27];
c = [4 3 2];
d = [1; 2; 3];
%% a
fprintf('4.(a) ');
fprintf('A*B= ');
disp(A*B);
fprintf('B*A= ');
disp(B*A);
fprintf('c*B= ');
disp(c*B);
fprintf('A*d= ');
disp(A*d);
%% b
fprintf('4.(b) ');
C = [A B]
D = [B;c]
%% c
fprintf('4.(c) ');
x = A
%% d
fprintf('4.(d) ');
b_transpose = b'
c_transpose = c'