Iterate through a logical array

Assignment Help Basic Computer Science
Reference no: EM131222420

You must use either for or while to solve the following problems.

a. Iterate through a vector, A, using a for loop and create a new vector, B, containing logical values. The new vector should contain true for positive values and false for all other values.
For example, if

2278_d8277927-d4ad-4f67-9d10-422c93fe0a09.png

b. Iterate through the vector, A, using a while loop and return a new vector, B, containing true for positive values and false for all other values.

c. Iterate through a logical array, N, using a for loop and return a new vector, M, containing the value 2 wherever an element of N is true and the value -1 (not a logical value) wherever N is false. For example, if
N = [true false false true true false true] the result should
be M = [2 -1 -1 2 2 -1 2]

d. Iterate through an array, Z, using a while loop. Replace every element with the number 3 until you reach a number larger than 50. Leave the rest unchanged. For example, if
Z = [4 3 2 5 7 9 0 64 34 43], after running your script,
Z = [3 3 3 3 3 3 3 3 34 43]

 

 

Reference no: EM131222420

Questions Cloud

How is maintenance planned and controlled : Does your organization collect quantitative data on maintenance activities? If so, what type of data, and how are they used to guide and improve the maintenance process? If not, how is maintenance planned and controlled?
Do you have clear and easily definable boundaries : The model of a good corporation, then, is not one that is too rigid and organized, but one that is capable of exploring the possibilities contained within its body without organs. What would such a corporation look like? Do you think such a corpor..
Simulation experiment using a statistical computer package : Consider the four sample sizes n = 10, 20, 30, and 50, and in each case use 500 replications - For which of these sample sizes does the x‾ sampling distribution appear to be approximately normal?
Describe the type of bond investment program : Describe the type of bond investment program you think the Shuman family should follow.- List several types of bonds that you would recommend for their portfolio and briefly indicate why you would recommend each.
Iterate through a logical array : Iterate through the vector, A, using a while loop and return a new vector, B, containing true for positive values and false for all other values.
What are some different types of stakeholders : Pick a business and describe the various stakeholders that the business has. Why are these people stakeholders? What responsibilities does the business have to these stakeholders?
Value of investment after one year : a. What is the value of your investment after one year? Multiply $3,000 × 1.12. b. What is the value of your investment after two years? Multiply your answer to part a by 1.12. c. What is the value of your investment after three years? Multiply your ..
What are various ways in which the textbook proposes : What are various ways in which the textbook proposes that our understanding of the corporation to its stakeholders can be revised? What are some of the benefits and drawbacks to each proposal?
Financial statements of the company : What impact does the grant of these options have on the financial statements of the company? Explain Answer please.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Discuss the different types of advance directives

Discuss the different types of advance directives and the pros and cons of each. Do you have an advance directive? Has what you have learned this unit caused you to consider the need for one? Why or why not?

  Generate sql statements to create the final database

Use Designview to check your answers to exercises that call for computing closures, testing normal forms, decomposing into a desired normal form, and so on.

  Question regarding the maintain participant interest

Develop a 1,050- to 1,400-word overview for a training program on diversity and inclusion for your organization's first line supervisors. Include a plan for the types of exercises, roleplaying, or activities that will maintain participant interes..

  Allow a grocery store to keep track of the total number

Write a program that will allow a grocery store to keep track of the total number of bottles collected for seven days.  The program should allow the user to enter the total number of bottles returned for seven days.  The program will

  Find out the generic format for tcp header

Suggest an extension to TCP allowing the sender of an option a way of specifying what the receiver should do if the option is not understood. List several such receiver actions that might be useful, and try to give an example application of each.

  Method called is isosceles that accepts three integers

The method returns true if the triangle is isosceles but not equilateral (meaning that exactly two of the sides have an equal length), and false otherwise.

  Are there any for which both are reasonable

Most round-robin schedulers use a fixed size quantum. Give an argument in favor of a small quantum. Now give an argument in favor of a large quantum. Compare and contrast the types of systems and jobs to which the arguments apply. Are there any fo..

  Java interface construct to formally specify

What are the benefits we accrue by using a Java interface construct to formally specify the logical level of ADTs?Suppose we have a linked list of Strings, as defined in the textbook, named presidents. Suppose it contains three nodes, with the fir..

  Explain what is meant by a "query".

Explain what is meant by a "query".Explain what is meant by a "query".

  Why is requirement management important

Why is requirement management important? Why it is needed? What is the process flow for requirement management?

  Computer the value of the given number

Prompt the user for a number and an exponent. Computer the value of the given number (the base) raised to the power of the exponent.

  Purchase a pre-built personal computer

Purchase a pre-built personal computer

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd