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

Matlab Programming 1. Write a Matlab program that reads in two numbers, lo and h

ID: 3723550 • Letter: M

Question

Matlab Programming

1. Write a Matlab program that reads in two numbers, lo and hi, and counts how many numbers between lo and hi that are a multiple of 3.

2. Write a Matlab program that accepts three parameters "lowerLimit", "upperLimit", and "factor". The program should display all the numbers between "lowerLimit" and "upperLimit" that are a multiple of "factor". Use the "input" function to read in lowerLimit, upperLimit, and factor. You will need to use the int32 function on the inputs to convert them to integers. Example: If lowerLimit = 20, upperLimit = 30, and factor = 7, the output should be 21, 28.

Explanation / Answer

2) lowerLimit = input("Enter lower limit");

upperLimit = input("Enter upper limit");

factor = input("Enter factor");

lowerLimit = int32(lowerLimit);

upperLimit = int32(upperLimit);

factor = int32(factor);

for i = lowerLimit:1:upperLimit

    if( mod(i,factor) == 0)

        disp(i);

1) lo = input("Enter lower limit");

hi = input("Enter upper limit");

lo = int32(lo);

hi = int32(hi);

count = 0

for i = lowerLimit:1:upperLimit

    if( mod(i,3) == 0)

        count = count + 1;

disp(count);