结构化程式和自定义函数

Script
1.注解 %
2.%% run section
3.debug---breakpoint
  command window:K>>
4.smart index---快速改排版
5.Flow Control
  if(Rational Operation)
  ~=---不等于
6.loop末尾加end
7.F5---执行,在command window显示运行结果
8.ram(a,b)---a对b取余
9.prod(1:n)---n的阶乘
10.pre-allocating Space to Variables---节省计算时间
11.tic—toc:算运行时间
12.Tips for Script Writing
  ...换行号
  crtl+c---跳出宕机
13.functions
  scripts:NO input/output/in global
  function: / /local workspace
function y=mean(x)
keyword output functionname(input)
comment
code
14.点乘 vector中各元素进行运算
15.  function [a F]=acc(v2,v1,t2,t1,m)
     a=(v2-v1)./(t2-t1);
     F=m.*a;
16.
17.function handle--函数句柄---pointer(指向)
  f=@(x) exp(-2*x);
  x=0:0.1:2;
  plot(x,f(x));

posted @ 2018-08-07 22:26  SUMay  阅读(208)  评论(0编辑  收藏  举报