First please write a MATLAB function that finds all the divi

First, please write a MATLAB function that finds all the divisors between 2 and 20 of an integer. Your function header should be function div = finddi visor (a) when\' the input a is an integer, the output div is a. vector that contains all of the divisors of a that are between 2 and 20. For example, if the input is 42, its divisors between 2 and 20 are 2,3,6,7,12.14 18 (21 is also a divisor of 42, but larger than 20, so does not count here\') The rmtrmt should be div = [2 3 6 7 12 14 18], P Once you construct your MATLAB function fmddivisor, use it to find all the divisors (between 2 and 20) of your WSU student ID number.

Solution

main program:

clc
clear all
a=input(\'enter any integer\');
[div]=finddivisor(a)

sub function:

function [div] = finddivisor(a)
c=1;
for i=2:1:20
if (rem(a,i)==0)
div(c)=i;
c=c+1;
end
end

 First, please write a MATLAB function that finds all the divisors between 2 and 20 of an integer. Your function header should be function div = finddi visor (a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site