1 / 5

Introduction to Engineering MATLAB – 7 Script Files - 2

Introduction to Engineering MATLAB – 7 Script Files - 2. Agenda Script files continued. EXAMPLE. Write a script file that determines the balance in a saving account at the end of every year for the first 10 years. Initial investment of $1,000 and interest rate of 6.5% compounded annually.

lbetts
Télécharger la présentation

Introduction to Engineering MATLAB – 7 Script Files - 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to EngineeringMATLAB – 7Script Files - 2 Agenda Script files continued

  2. EXAMPLE Write a script file that determines the balance in a saving account at the end of every year for the first 10 years. Initial investment of $1,000 and interest rate of 6.5% compounded annually. Display the information in a table. For an initial investment of A, and interest rate of r, the balance B after n years is given by:

  3. SOLUTION Referenced in first MATLAB lecture format bank yr = [1:10]; % Creating a vector of year numbers. balance = 1000*1.065.^yr; % Creating a vector of the balance. table_yr_blnc(:,1)=yr'; % Substituting the yr vector in the first column of the table matrix. table_yr_blnc(:,2)=balance'; % Substituting the balance vector in the second column of the table matrix. disp(' YEAR ACCOUNT') % Display titles. disp(' BALANCE ($)') % Display titles. disp(' ') % Display an empty line. disp(table_yr_blnc) % Display the table.

  4. SOLUTION Executing the script file in the command window gives: >> Lecture4Example4 YEAR ACCOUNT BALANCE ($) 1.00 1065.00 2.00 1134.22 3.00 1207.95 4.00 1286.47 5.00 1370.09 6.00 1459.14 7.00 1553.99 8.00 1655.00 9.00 1762.57 10.00 1877.14

  5. ASSIGNMENT 5: • 1. Problem 32 page 61 in the textbook. • Problem 33 page 61 in the textbook. • Problem 4 page 161 in the textbook. For each problem write a script file and execute it in the command window. For each problem, the first two lines of the script file are: % Assignment 5, Problem (write the number of the problem) % Name: (first name, last name) Submit a printout of the script file, and a printout of the command window.

More Related