Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

matlab problem Write code to find all numbers between 1 and 10000 (inclusive) that are multiples of 5 or multiples of 7, but not both.

matlab problem image text in transcribed
Write code to find all numbers between 1 and 10000 (inclusive) that are multiples of 5 or multiples of 7, but not both. Write the code three ways: all answers should be identical: a. Write this code using a for loop, looping through all integers between 1 and 10000. At each step of the loop, check if the loop index is a multiple of 5 or 7 but not a multiple of both; if it is, store it in a vector. Save your solution, which should be a row vector (1 row) of all such numbers, as x57a (2 points). b. Write this code using a while loop. Your code may be very similar, or not, either is fine. Save your solution, which should be a row vector, as x57b (1.5 point). c. Write this code without using loops. Start with x=1:10000, then use logical indexing, the find function, or some other method to identify only those elements which are multiples of 5 or 7 but not multiples of both. Save your solution, which should be a row vector (1 row) as above, as x57c (1.5 point)

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

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

please dont use chat gpt 6 9 4 .

Answered: 1 week ago

Question

Cite some of the contemporary challenges facing HRD professionals

Answered: 1 week ago

Question

13-4 What are alternative methods for building information systems?

Answered: 1 week ago