What is the value of y in the code


Complete the mcq:

Q1) Which is the correct matlab logical expression to check whether the value of x is between -10 and 10 (inclusive)?

a) -10 <= x <=10
b) -10<= x, X <= 10
c) x>=-10 & X<=10
d) x>=-10| x<=10
e) none

Q2) Assuming that x is a vector that allready exists, what is the value of y after the following code is executed?

y = x(1);
for k=2:length(x)
if x(k) >y
y=x(k);
end
end

a) the last element in x
b) the first elemtn in x
c) the max element in x
d) the min element in x
e) none

Q3)Add one or two statements to complete the following code that implements question 12 using vectors instead of a loop.

x=1.5;
N=50;
k=[0:2:100];

Q4) Which of the following is the corect code to determine y=1 + 1/x+1/x^2+1/x^3..+1/x^N until the last term is less than 10^-8, using x=1.5

and is c) but why?? x=1.5; k=0; y=o; term=1/(x^k); while term >= 1e-8; y=y+term

Solution Preview :

Prepared by a verified Expert
MATLAB Programming: What is the value of y in the code
Reference No:- TGS01938828

Now Priced at $25 (50% Discount)

Recommended (96%)

Rated (4.8/5)