Question: Write a Matlab script called cubes.m which declares a vector of numbers, A, and creates a new vector B containing the cubes of the positive
Write a Matlab script called cubes.m which declares a vector of numbers, A, and creates a new vector B containing the cubes of the positive numbers in A. If an element is negative, put zero in the corresponding position in B. Your solution must use a loop to iterate through the vectors. The following example specifies the minimum output: Given A [1, 2,-1, 5, 6, 7,-4, 3, -2, o >cubes B= 1 8 0 125 216 343 0 27 00
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
