1. Create a function that calculates N!, where N is an input variable to the function....

1. Create a function that calculates N!, where N is an input variable to the function. Use a for loop and calculate the factorial without using the factorial function built into MATLAB.

2. Prof. Sky wants to retire when his retirement account first reaches or exceeds $2,000,000. He deposits $20,000 at the beginning of every year into the account which pays 9% interest per year, compounded annually. Create a function that calculates how many years Prof Moss will have to teach before he can retire? (Hint: assume a $20,000 initial balance for year 0.)

3.Generate a vector of 1 million random numbers that are normally distributed. Plot the points in a histogram with 100 bins.


Homework Answers

Answer #1

Matlab Code:

function [ fact ] = factorialNumber( N )
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
fact = 1;
for i = 1:1:N
fact = fact*i;


Sample Run:

>> factorialNumber( 4 )

ans =


>> factorialNumber( 5 )

ans =




Matlab Code:

r = rand(1,1e6);
xlabel 'bins'
ylabel 'Random Value'
title 'Histogram of Random Numbers'




Matlab Code :


year = 0;
amount = 20000;

while (amount < 2000000)
amount = amount + ((amount*9)/100);
year = year + 1;

sprintf('No of Years Reuired = %d',year)


output :

ans =

No of Years Reuired = 54


Dont Forget to hit like....

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
Active Questions
  • Sharp Company manufactures a product for which the following standards have been set: Standard Quantity or...
    asked 13 minutes ago
  • Case 12.1 Determine what variables are categorical (either nominal or ordinal scales), perform the appropriate descriptive...
    asked 18 minutes ago
  • GDebi Enterprises is thinking of building a chemical processing plant to produce 4-hydroxy-3-methoxybenzaldehyde. The firm estimates...
    asked 18 minutes ago
  • Suppose you are picking one number from the set of natural numbers from 97 to 4....
    asked 25 minutes ago
  • What is the wavelength (in meters) of photons with the following energies? Part A.) 136 kJ/mol...
    asked 26 minutes ago
  • In your own words, define nonverbal communication and explain three differences between verbal and nonverbal communication...
    asked 30 minutes ago
  • A new fuel injection system has been engineered for pickup trucks. The new system and the...
    asked 35 minutes ago
  • Robots can be trained to do dangerous, stinky, montonous work that human may not want to...
    asked 36 minutes ago
  • Steam at 250oC and 1 MPa enters a compressor at a steady rate of 2 m3...
    asked 36 minutes ago
  • What is the Cost of Equity? Provide a definition, and suggest least one way that we...
    asked 42 minutes ago
  • The scores of fourth grade students on a mathematics achievement test follow a normal distribution with...
    asked 49 minutes ago
  • The chief cost accountant for Kenner Beverage Co. estimated that total factory overhead cost for the...
    asked 56 minutes ago