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

Matlab Programming 3. Write a Matlab program that accepts four parameters \"lowe

ID: 3723551 • Letter: M

Question

Matlab Programming

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.

Explanation / Answer

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