Create a variable named c and assign to it a 15 element row vector whose first a
ID: 2079362 • Letter: C
Question
Create a variable named c and assign to it a 15 element row vector whose first and last elements have value and -10 and +10, respectively. Use the built-in linspace () function Create a variable named h and assign to it a row vector whose elements have values obtained by evaluating the mathematical expression shown below for corresponding elements of row vectors a and c. Utilize the built-in function nth root () when evaluating 3 Squareroot c/a. h = 20 sin^2(2a + (pi/4)) cos(5c - (pi/3)) + 6(3 Squareroot c/a)/(a - c)Explanation / Answer
a) To create a row vector c
c = linspace(-10,10,15);
This is the MATLAB command. Here the first element "linspace(X1,X2,n)" here X1 and X2 defines the range and n defines the number of points.
b) for b part, Here you have not specified the row vector a, so i m assuming it to my choice.
I cannot assume it to be same as row vector c, as it will lead to inf term in h.
a=linspace(1,9,15);
h= 20* (sin(2*a+pi/4)).^2 .* cos (5*c -(pi/3) )+6*nthroot(c./a,3)./(a-c);
here you can see i have added a dot "." before multiplication, this is done because it is matrix multiplication. If u dont add a dot, it will not create a matrix after the operation. Or you can make use of for loop and do the same.
for calculating nthroot(X,N) where X is the variable value, and N is the root, i.e. 3 for cube root.
%% Matlab Code
c = linspace(-10,10,15);
a=linspace(1,9,15);
h= 20* (sin(2*a+pi/4)).^2 .* cos (5*c -(pi/3) )+6*nthroot(c./a,3)./(a-c)
%% Output
c =
Columns 1 through 12
-10.0000 -8.5714 -7.1429 -5.7143 -4.2857 -2.8571 -1.4286 0 1.4286 2.8571 4.2857 5.7143
Columns 13 through 15
7.1429 8.5714 10.0000
a =
Columns 1 through 12
1.0000 1.5714 2.1429 2.7143 3.2857 3.8571 4.4286 5.0000 5.5714 6.1429 6.7143 7.2857
Columns 13 through 15
7.8571 8.4286 9.0000
h =
Columns 1 through 12
0.5508 8.9535 9.4102 -0.9338 -14.5375 -12.6795 -1.0104 9.5647 7.8924 5.0746 2.9020 1.7900
Columns 13 through 15
-1.9284 -52.1215 -6.1935
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.