《《MATLAB及其工程应用》第7讲课件》由会员分享,可在线阅读,更多相关《《MATLAB及其工程应用》第7讲课件(13页珍藏版)》请在金锄头文库上搜索。
1、MATLAB return;,How to call a function,d = dist2(0, 0, 3, 4);,Function with multiple outputs,function r, theta = rect2polar(x, y) % RECT2POLAR convert rectangular to polar coordinates % . r = sqrt( x.2 + y.2); theta = 180/pi * atan2(y, x);,Function calling,Calculate the value of s for a given n. s =
2、1! + 2! + 3! + n!,How to solve?,Write a function to get the factorial value of x ( factorial_1(x) = x! ) Write the code to sum up all the factorial values from factorial_1(1) to factorial_1(n),Think more,How to reduce the operations? Is there a build-in MATLAB function to calculate the factorial value ? How to find a MATLAB build-in function if you never used before?,Assignment:,Excises 5.9, 5.23,