Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Say we have an array x whose elements represent the boundaries of different bins. Bin 1 is the set of numbers between the first and

Say we have an array x whose elements represent the boundaries of different bins. Bin 1 is the set of numbers between the first and second entries of the x array, Bin 2 is the set of numbers between the second and third entries, and so on. We'd like to write code that takes a scalar input image text in transcribed and returns an index indicating which bin image text in transcribed belongs to.

As an example, suppose we have

binArray = [1, 2.2, 4.1, 5, 7.5, 9]

If we input image text in transcribed , we want the code to return a 2 because 3.8 is in the 2nd bin (it's between image text in transcribed and image text in transcribed). Similarly, if we input image text in transcribed, our code should return a 5, since 8.4 is in the image text in transcribed bin. If image text in transcribed lies on one of the bin boundaries, we'll assign it to the bin on the right. If image text in transcribed lies on the last data point, we'll assign it to the bin on the left. (So image text in transcribed is in bin 2, and image text in transcribed is in bin 5.)

Create a function file to do this. For the bins, we will use an array of randomly generated numbers as indicated in the code outline.

The function starts like this:

function bin = binFind(x0)

rng(2019)

binArray = 20*rand(1,100);

binArray = sort(binArray,'ascend');

can test with this:

%As a test, binFind(15) = 72

binFind(15)

%binFind(pi) = 8

binFind(pi)

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

Students also viewed these Databases questions

Question

Explain the photoelectric effect.

Answered: 1 week ago

Question

Comment should this MNE have a global LGBT policy? Why/ why not?

Answered: 1 week ago