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

Matlab Program, DO NOT USE FOR LOOPS 3. Write a Matlab program that accepts four

ID: 3728223 • Letter: M

Question

Matlab Program, DO NOT USE FOR LOOPS

3. Write a Matlab program that accepts four parameters "lowerLimit", "upperLimit", "A", and "B". The program should display all the numbers between "lowerLimit" and "upperLimit" that are a multiple of "A" but not a multiple of "B". Use the "input" function to read in lowerLimit, upperLimit, A, and B. You will need to use the int32 function on the inputs to convert them to integers. Example: If lowerLimit = 10, upperLimit = 20, A = 3, and B = 5, the output should be 12, 18. The number 15 is not printed because although it is a multiple of 3, it is also a multiple of 5 and therefore not printed.

4. Modify the previous program to count how many numbers were printed out, and print out that total.

Explanation / Answer

3)

Using of while loop

Code

function [z] = LowerUpperLimit (lowerLimit,upperLimit,A,B)
lL=int32(lowerLimit)
uL=int32(upperLimit)
a=int32(A)
b=int32(B)

while(lL<=uL)
if(mod(lL,a) ==0 && mod(lL,b)!=0)
disp(lL)
end
lL=lL+1;
end
endfunction

Thank You