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

Need Help 3. Use a for loop to sum the elements in the following vector: V [10,

ID: 2267619 • Letter: N

Question

Need Help

3. Use a for loop to sum the elements in the following vector: V [10, 27, -66, 43, 72, 87, 56, 98, 33, 23.5, 8.5, 77.7, 36, 24, 11, 85, 55, 63, 4, 39, 100,-96, 4, 41, 189, -9, 78.3, -83] You will need to first determine the size of the vector Check your answer using the sum function 4. Repeat the previous problem, this time using a while loop 5. Create a function called "isInt" to check whether an input number is an integer. The function should display a sentence of the form: "22.5 is not an integer!" or "99 is an integer!" if the inputs were respectively 22.5 and 99 In each of the following questions (6. & 7.), first, evaluate the given MATLAB code for each of the test cases without using MATLAB. Then, using MATLAB, check the answers you obtained first. 6. ifn> 1 m = n+1 b. n=2 c.n=10 m- m- m- elseif n==0 m=n else m = n-10 end a. letter = 'p' b. lettery c. letter = 'g' d. letter 'Q' e. letter- x 7. Switch letter case 'x' case 'y', 'Y' case 'Q otherwise disp ( 'Hello, ) disp ( 'Yes') disp ( 'Quit' ) disp ('Error') end Note: When you copy and paste codes into MATLAB, some characters may not correctly translate. As a result, you may have to correct them for the script to run properly.

Explanation / Answer

Hello,
       Please find the answer attached below. If the answer has helped you please give a thumbs up rating. Thank you and have a nice day!

Since there are multiple questions, I have answered the first two (in the same matlab file):

**** Matlab Code ******

%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Sum of elements in array using for loop and while loop

V = [10 27 -66 43 72 87 56 98 33 23.5 8.5 77.7 36 24 11 85 55 63 4 39 100 -96 4 41 189 -9 78.3 -83];
sum_V = 0;

for i=1:size(V,2)                                                       % for loop
    sum_V = sum_V + V(i);
end

fprintf('The sum with for loop is %f ',sum_V);                         % printing results
fprintf('The sum using the MATLAB sum option is is %f ',sum(V));       % validating with sum function

sum_V = 0;
i=1;
while(i<=size(V,2))                                                     % while loop
    sum_V = sum_V + V(i);
    i=i+1;
end

fprintf('The sum with while loop is %f ',sum_V);

**** End of Code ******

Output:

The sum with for loop is 1011.000000
The sum using the MATLAB sum option is is 1011.000000
The sum with while loop is 1011.000000

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote