40 likes | 167 Vues
conversion factor functions. should be simple - not complex. ft_to_m: 0.3048. fpminsq_to_mpssq: 0.00008467. min_to_s: 60. convert acc = 325 ft/min/min to m/s/s. acc*ft_to_m/min_to_s/min_to_s. = 325*0.3048/60/60 = 0.02751666666667. acc* fpminsq_to_mpssq.
E N D
conversion factor functions should be simple - not complex ft_to_m: 0.3048 fpminsq_to_mpssq: 0.00008467 min_to_s: 60 convert acc = 325 ft/min/min to m/s/s acc*ft_to_m/min_to_s/min_to_s = 325*0.3048/60/60 = 0.02751666666667 acc* fpminsq_to_mpssq = 325*0.00008467 = 0.027517750000000 = 325*0.0000847 = 0.027527500000000 we want to maintain as much accuracy as possible avoid ROUNDOFF errors Engr 0012 (04-1) LecNotes 08-01
annotating your scripts and functions function [principal, balance, rate, years] = calcinfo( ) % get user input to financial calculation problem % needs: nothing % returns: stuff user entered % ... function [principal, balance, rate, years] = calcinfo( ) % get user input to financial calculation problem % needs: nothing % returns: principal principal invested, $ % balance balance after years, $ % rate annual interest rate, % % years number of years invested, years % ... Engr 0012 (04-1) LecNotes 08-02
display of results is limited disp( ) will display the text disp( 'A line of text' ) will display value of var_name disp( var_name ) but - only under current format full control of everything - Workshop 5 fprintf('control string', value list) fprintf('\nInvesting a prinicpal of $%12.2f', principal) fprintf('\nfor %6.2f years at %6.3f%%', years, rate) fprintf('\ncreates a balance of $%12.2f', balance) Engr 0012 (04-1) LecNotes 08-03
programming assignment 04 due Wed 24 Sep class activity 08 : ca08_e12(04-1).pdf Engr 0012 (04-1) LecNotes 08-04