Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

answer each question with the code (1 point write the number 0.0035 using expone

ID: 3846376 • Letter: A

Question


answer each question with the code

(1 point write the number 0.0035 using exponential notation (2 Points) Ask the user to enter their name and store it in a variable: d) (3 Points) Using the variable from c) above, when the name entered is Davison, say welcome professor. Otherwise tell the user whether or not the name they entered starts with the letter "D ne) (4 en code that will determine the result of Points) You are given a matrix m. Write summing up all the values in the matrix. ..ene (2 Points) Generate a random number from 1.5 to 3.5 and store it in a variable. rant

Explanation / Answer

Here is the matlab code for the question. Please don't forget to rate the answer if it helped. Thank you very much.

%question 1, prints 0.0035 in exponential format i.e 3.5000E-03
format shortE
x = 0.0035

%question 2, ask user for input name

name1 = input('Enter your name:', 's');

%question 3, compare user input with string Davison
name2 = 'Davison';
if (strcmp(name1 , name2))
fprintf("Welcome professor %s ", name1);
else
if(name1(1) == 'D') %get the 1st character in the name and compare with 'D'
fprintf("Your name starts with D ");
else
fprintf("Your name does not start with D ");
end
end

% question 4, summing matrix elements
format short
m = [1 2; 3 4]
%sum returns a row matrix by summing the columns in a matrix
total = sum(m);

%keep calling sum, till we end up with a single element in the total
%store the result back into total
while(numel(total) != 1)
total = sum(total) ;
end

total

%question 5, generat random number in a range
%define the lower and higher end of range and then generate random number
%using rand() function
lo = -5;
hi = 5;
r = lo + (hi - lo) * rand()

output

x =    3.5000E-03                                                                                                             

Enter your name:Davison                                                                                                       

Welcome professor Davison                                                                                                     

m =                                                                                                                           

                                                                                                                              

   1   2                                                                                                                      

   3   4                                                                                                                      

                                                                                                                              

total =  10                                                                                                                   

r = -4.7515