Question
PLease answer the question with proper functions using matlab 1. Write a function that takes two inputs (maximum and divisor as scalars) and returns to
PLease answer the question with proper functions using matlab
1. Write a function that takes two inputs (maximum and divisor as scalars) and returns to outputs (the numbers evenly divisible and the numbers not evenly divisible as vectors).
This function must use a for-loop
The function should determine for all positive integer numbers up to and including the maximum, if the number is evenly divisible by the divisor.
For Honors Credit, rewrite this function using a while-loop
2. Write a function that takes two inputs (maximum and divisor as scalars) and returns to outputs (the numbers evenly divisible and the numbers not evenly divisible as vectors).
This function must be vectorized (no looping)
The function should determine for all positive integer numbers up to and including the maximum, if the number is evenly divisible by the divisor.
Attempt for question 1
function [Integer, noninteger ]= Question 1(m,d) %m= scalar (maximum) %d= scalar (divisor) k=0; l=0; for i=1:1:m if mod(i,d)==0 l=1+1; integer (1)=i; return else k=k+1; noninteger (k)=i; endStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started