Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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; end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

Students also viewed these Databases questions

Question

of tralle Hechuired of tralle Hechuired

Answered: 1 week ago

Question

5. Explain the supervisors role in safety.

Answered: 1 week ago

Question

7. Explain how an employee could reduce stress at work.

Answered: 1 week ago