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

PREDICT THE OUTPUT FROM EACH OF THE FOLLOWING MATLAB PROGRAMS. In each of the be

ID: 3699851 • Letter: P

Question

PREDICT THE OUTPUT FROM EACH OF THE FOLLOWING MATLAB PROGRAMS. In each of the below syntax exercises, determine the output that results from running the specified MATLAB program. If there is no output because an error or an infinite loop results, write "ERROR" or "INFINITE LOOP" (whichever causes the problem) and then explain WHY the error or infinite loop occurs. If no error or infinite loop occurs, then write the output that results from running the program. You will need to show your work, meaning, demonstrate how you arrived at what you claim is the t from these programs. Remember: statements terminated with a semi-ccon do not produce output! Also... it will be beneficial to READ THE PROBLEM FIRST, to understand what's going on, rather than just jump right in. Finally...DO NOT USE MATLAB to work out the answers to these exercises

Explanation / Answer

initially A is
A=[0 0 0;
0 0 0
0 0 0]
B=[1 1 1;
1 1 1;
1 1 1];
C is equal to B
In exercise 4, the while loop runs as long as the sum of first row of A is less than or equal to sum of 3rd row of B, which is correct initially. However, inside the while loop, no changes are made to matrix A and B, so this condition will always be satisfied. Therefore this code will result in INFINITE LOOP
==================================================================================
In exercise 4 the condition is same as above but A nd B are changed inside, so the loop will terminate.when n becomes 1 in the first iteration, and A and B are redefined, the while loop condition will fail and loop will break out. The output will be
A = [2 2 2;
2 2 2;
2 2 2]
B= [1 1 1;
1 1 1;
1 1 1]

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