Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

X Use a for loop to fill in an array || 6 solutions submitted (max: 10) | View my solutions One of the most common

image text in transcribed

X Use a for loop to fill in an array || 6 solutions submitted (max: 10) | View my solutions One of the most common applications of for loops in MATH 307 is to fill in the entries of an array one at a time. x = [x(1), (2), (3), ... ,x(i), ..., x(n)]; I have an array of length 250 named x with random integers from 1 to 10. Create a corresponding array where each entry is computed using the following criteria If the entry in x is less than 4, define the corresponding entry in y to be 0. If the entry in x is between 4 and 7 (inclusive), define the corresponding entry in y to be twice the entry in x. If the entry in x is greater than 7, define the corresponding entry in y to be 100. Script 1 rng(307); % so the random numbers are the same 2 x = randi(10,1,250); % random integrs from 1 to 10, of size 1x250

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_2

Step: 3

blur-text-image_3

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

What are incidence rates? How do they affect the sample size?

Answered: 1 week ago