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

  Compute the power absorbed by the inductor

For the circuit shown in Figure P4.40(a) , the current i ( t ) is shown in Figure P4.40(b) .

  Design of a bus arbitration sequential circuit for computer

If all input variables are 0, it sets all output variables to 0. Design two such arbitration circuits, one that grants priority to the lowest indexed input that is 1 and a second that grants priority alternately to the lowest and highest indexed i..

  How does it guarantee serializability

What is the two-phase locking protocol?

  Controlling and providing support for all essential function

The motherboard is the central part of a PC, controlling and providing support for all essential functions. Search the Internet for one website on either Motherboard manufacturers or a website that provides technical reviews of motherboards. Share..

  Describe the scope of the project and control measures

Describe the scope of the project and control measures. Describe the goals and objectives of the project. Give a detailed, realistically estimated cost analysis of the entire project.

  What differences might you expect to find

What differences might you expect to find

  Explaining advantages of ansi-tia-eia cabling standards

Discuss in scholarly detail the advantages of the ANSI/TIA/EIA cabling standards.

  What does it take to be successful in business

What does it take to be successful in business? Explain how entrepreneurs differ from business managers. What characteristics do they share? Discuss an example of a successful entrepreneur.

  Write and explain the definition of composition in c++

Write and explain the definition of composition in C++ and how it is useful in writing object-oriented programming. Also, explain how it is different from inheritance and how both inheritance and composition are useful in developing object-oriente..

  Determine the primary number of turns

The secondary of a 750 KVA, 11000/ 400 V, 50 Hz transformer has 160 turns. Determine the primary number of turns, primary and secondary full load current neglecting losses. If the area of cross section of the core is 100 cm2, what will be flux dens..

  Design the server to handle clients concurrently

Note that all of the work of authenticating the user and starting a login shell can be dealt with in each server child by having the (grand)child created by ptyFork() go on to exec login(1).

  Explaining costs are classified as opex or capex

The managers of the five business units. They will need to know the following about each option in terms that nontechnical staff can readily understand: Whether the costs are classified as opex or capex.

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