These questions accompany the online MATLAB learning material at matlab.zyante.com.

Solved

Number of pennies

Complete the function ConvertToPennies() so that the function returns the total number of pennies given a number of dollars and ...

5 years ago

Solved

Prime checker

Complete the recursive function to determine if a number is prime. Skeletal code is provided in the PrimeChecker function.

5 years ago

Solved

Writing a recursive math function

Complete the recursive function RaiseToPower(). Ex: If userBase is 2 and userExponent is 4, then raisedValue is assigned wit...

5 years ago

Solved

Moving target

Write a function with persistent variables currentLocationX and currentLocationY that store an object's location. Each call to t...

5 years ago

Solved

Travel speed

Write an anonymous function to compute the Euclidean distance given two points (x1, y1) and (x2, y2). Use the following equation...

5 years ago

Solved

Writing a nested function: BMI calculation

Write a nested function CalculateBMI that assigns bmiValue given a user's weight and height. Use the following equations to calc...

5 years ago

Solved

Writing a function: MaxValue()

Write a local function named MaxValue that returns the maximum of two inputs numA and numB.

5 years ago

Solved

Function call: Kilometers to miles

Assign rateMPH with the corresponding rate in miles per hour given a user defined rateKPH, which is a rate in kilometers per hou...

5 years ago

Solved

Modify an array's elements using other elements

Write a for loop that sets each array element in bonusScores to the sum of itself and the next element, except for the last elem...

5 years ago

Solved

Modify an array's elements

Write a for loop that iterates from 1 to numberSamples to double any element's value in dataSamples that is less than minValue. ...

5 years ago

Solved

Finding values in arrays

Assign numMatches with the number of elements in userValues that equal matchValue. Ex: If matchValue = 2 and userVals = [2, ...

5 years ago

Solved

Populating an array with a for loop

Write a for loop to populate multiplicationTable with the multiples of baseValue from 0 to 5. Ex: If baseValue is 2, then mu...

5 years ago

Solved

Double summation

Write two nested for loops to calculate the following double summation: <<https://drive.google.com/uc?id=0B74PAULDIwwsWFhlNTV...

5 years ago

Solved

For loops: Odds sum

Write a for loop that assigns summedValue with the sum of all odd values from 1 to userNum. Assume userNume is always greater th...

5 years ago

Solved

For loops: Savings account

The for loop calculates the amount of money in a savings account after numberYears given an initial balace of savingsBalance and...

5 years ago

Solved

Insect population

An insect population doubles every generation. * Write a while loop that iterates numGeneration times. * Write a statment ...

5 years ago

Solved

While loop with branching

Write a while loop that adjusts userValue while userValue is less than 0 or greater than 80. If userValue is greater than 80, th...

5 years ago

Solved

While loop with multiple conditions

Write a while loop that multiplies userValue by 2 while userValue is not 10 and while userValue is less than 25.

5 years ago

Solved

Writing a while loop

Write a while loop that continues to increment userValue by 5 until userValue is less than 0.

5 years ago

Solved

Preset rpm speeds

A centrifuge has four preset speeds. Write a switch statement that assigns rpmSetting with the appropriate rpm speed given prese...

5 years ago

Solved

Convert letters to Greek letter

Write a switch statement that checks origLetter. If origLetter is 'a' or 'A', assign greekLetter with 'Alpha'. If origLetter is ...

5 years ago

Solved

Genetic markers test

Assign testResult with 1 if either geneticMarkerA is 1 or geneticMarkerB is 1. If geneticMarkerA and geneticMarkerB are both 1, ...

5 years ago

Solved

Food safety

Assign safeTemperature with 1 if foodTemperature is less than 40 or greater than 165.

5 years ago

Solved

Check bounds

Assign inRange with 1 if userWeight is greater than 100 and less than or equal to 200.

5 years ago

Solved

Multiple if statements

Write an if-statement that subtracts 5 from outputValue if amplitudeResponse is greater than 10. Write a second if-statement tha...

5 years ago

Solved

Dosage by weight

A machine administer's medication dosage based on weight. Write an if-elseif-else statement that assigns the appropriate dosageA...

5 years ago

Solved

Small aircraft weight limit

Write an if-else statement that evaluates to true if the sum of passengerWeight and cargoWeight is less than or equal maxWeight....

5 years ago

Solved

Equality check: Number of bricks

Write an if statement that assigns deliveryComplete with 1 if bricksDelivered is equal to bricksExpected.

5 years ago

Solved

Bridge toll

Complete the example to calculate finalToll. The base toll for a bridge is baseToll. If the vehicle's weight is over 5,000 pound...

5 years ago

Solved

Assignment statements based on input value

Write an if-else statement that assigns finalValue with userValue + 5 if userValue is greater than 100. Otherwise assign finalVa...

5 years ago