Matlab Function and Input -
function area = traparea(a,b,h) % traparea(a,b,h) computes area of trapezoid given % dimensions a, b , h, , b % lengths of parallel sides , % h distance between these sides % compute area, suppress printing of result area = 0.5*(a+b)*h;
this example. know how declare values suppose a=5,b=4,h=8 in seperate .m file , calling original function ie, traparea, using .in statement? example .in a=5 please help
if understand, want create script file. create filename called "myscript.m" (pick name like), , place in same folder "traparea.m" located. then, in file "myscript.m", put following:
a = 5; b = 4; h = 8; result = traparea(a,b,h) % 1 way show result fprintf('my result %f\n', result); % way display result
once have created 2 files "myscript.m", , "traparea.m", type "myscript" @ command line.
Comments
Post a Comment