CSE 7 Lecture 10: notes 2.1.17

37 views2 pages

Document Summary

Program: combination of a script (stored in a . m file)and the function (also stored in . m files) Volume of a hollow sphere is 4/3pi (r0. Where ro is outer radius and ri is inner radius. %calculates the volume of hollow sphere hollvol=4/3*pi*(outer^3 inner^3) end. %this scrips calculates the volume of a hollow sphere inner=input( enter the inner radius"); outer= input( enter the outer radius"); volume=vol_hol_sphere(inner, outer); fprintf( the volume is %. 2f\n, volume) this formats the volume to have two places of precision, floating point. Local variables the variables you create in your function definition are local to that function. Functions location: in a file with the same name as function. Use: type function name in command window with assignment of output and/or input arguments input/output: input(s) are arguments, output(s) are return values. Scope (local variable): function can access input arguments from command window and change only command window outputs.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents