永发信息网

matlab中function函数的具体用法

答案:3  悬赏:50  手机版
解决时间 2021-01-29 05:20
如题,在线等
最佳答案
1.新建一个m文件,把function函数复制进去;然后保存(名称应该是自动生成的,即为sinh.m,不过最好不要用和系统中的文件一样的名称,可以先help查看一下matlab是否有和sinh重复的名称,若有的话,得把function函数改个名称),保存的地址为当前工作目录。

2.在命令窗口调用function函数:

sinh(5)
全部回答
FUNCTION Add new function. New functions may be added to MATLAB's vocabulary if they are expressed in terms of other existing functions. The commands and functions that comprise the new function must be put in a file whose name defines the name of the new function, with a filename extension of '.m'. At the top of the file must be a line that contains the syntax definition for the new function. For example, the existence of a file on disk called STAT.M with: function [mean,stdev] = stat(x) %STAT Interesting statistics. n = length(x); mean = sum(x) / n; stdev = sqrt(sum((x - mean).^2)/n); defines a new function called STAT that calculates the mean and standard deviation of a vector. The variables within the body of the function are all local variables. See SCRIPT for procedures that work globally on the work- space. A subfunction that is visible to the other functions in the same file is created by defining a new function with the FUNCTION keyword after the body of the preceding function or subfunction. For example, avg is a subfunction within the file STAT.M: function [mean,stdev] = stat(x) %STAT Interesting statistics. n = length(x); mean = avg(x,n); stdev = sqrt(sum((x-avg(x,n)).^2)/n); %------------------------- function mean = avg(x,n) %MEAN subfunction mean = sum(x)/n; Subfunctions are not visible outside the file where they are defined. Normally functions return when the end of the function is reached. A RETURN statement can be used to force an early return.
我了个神啊,为了能用好matlab,我劝楼主还是稍微学学英语吧。其实也不用特别学,把help里不认识的英文单词查一查就差不多了。 要是连这点耐性都没有的话,建议楼主还是放弃编程吧。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
为什么有的快递是到邮局去领?
国考公务员报名时母亲的姓打错了字,现在进面
铁将军把门的意思是什么啊?知道的请说下!
哪些浏览器是谷歌内核的。
求个1024的账号用下,谢谢
兰州敦煌舞校地址在哪,我要去那里办事
广汽传祺GS4发动机变速箱可靠吗
愁惵的意思是什么啊?知道的请说下!
南康国际建材板材城交通方便吗?应该怎么过去
郑融 慢性伤害 的粤语那里能下到
下图是某实验小组做的“探究滑动摩擦力的大小
建湖广源驾校怎么去啊,我要去那办事
怎样代理万山利口红酒
为什么用微信零钱发红包时还要支付密码
在哪可以查看电影院播放的影片和票价??
推荐资讯
卵用鸡的意思是什么啊?知道的请说下!
香港机场到港岛太平洋酒店
电力猫是不是要一对才能用
三头不辨两的意思是什么啊?知道的请说下!
别人套用我的身份信息去贷款,我可不可以起诉
男生腿多长算长?
农垦职工培训中心地址在哪,我要去那里办事
春梅服装店地址在哪,我要去那里办事
允文允武的意思是什么啊?知道的请说下!
【我心蹦蹦跳】我心蹦蹦跳作文
古代科举考试前3名的人称什么
人民解放战争中,解放了东北全境的战役是A.
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?