MATLAB3.6-3.10

3.6循环控制语句之一:for/end

for循环可以由编译者控制选择循环的次数,需要完成一定的次数,而不是符合某个判断条件。一般格式如:
for 变量=起点:增量:终点
程序语句
end在这里插入图片描述
在这里插入图片描述

3.6循环控制语句之一:while/end

while循环,循环次数不由编译者规定,由判定条件决定,条件成立时进行循环,否则退出循环。循环格式如:
while 条件表达式
程序语句
end
在这里插入图片描述

3.8分支条件选择语句if/end;3.9多分支条件选择语句if/else if/…/else/end

条件选择语句的运行即为,条件的判断,在if语句中若条件成立,则运行if语句内的程序语句完成后跳到end,结束该条件选择语句,若不成立,则在else if语句中判断条件,若成立,运行其中的程序语句完成后跳到end,结束该条件选择语句,若不成立则继续在else if语句中判断,直到在else内运行,结束程序。
在这里插入图片描述
在这里插入图片描述

3.10 开关语句 switch/end

switch是多分支选择语句,执行指定程序语句。格式如下:
switch表达式
case 值 1
程序语句
case 值 2
程序语句
case 值 3
程序语句

otherwise
程序语句
end
在这里插入图片描述
在这里插入图片描述

注意:

在进行程序编写过程中,记得考虑已经赋值的字母对下次使用的影响。点乘与叉乘的区别:点乘是两个数组间的同一位置的数字进行计算,叉乘是两数组整体的运算。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
WHERE DOES THE TOOLBOX WORK? The toolbox has been tested on matlab 7.3 in Windows XP/Vista only. The toolbox uses features that are not compatible with matlab 4.x, so if you have matlab 4.x you should use version 1.04 of this toolbox instead. SETTING UP THE TOOLBOX In order to install the toolbox, simply (extract and) copy the files to a directory (e.g. NWAY). After copying all files, go to the 'update' homepage in order to see if newer versions of individual files are available. Copy these files indiviually overwriting the old files. Make sure that the updates are copied after the main files. Make sure that the path ../nway is included in MATLAB's path. If you have e.g. the PLS_toolbox, some files are named identically. This may cause problems depending on which functions you use. If you want to use e.g. the parafac function from the N-way toolbox, you have to ensure that either the path to the N-way toolbox appears before the path to the PLS_toolbox or that you run matlab from the nway directory. In order to get help on what files are present in the toolbox type <> at the matlab command line (if nway is the name of the directory where you have the files. DATA INPUT Unlike, older matlab 4 compatible versions of this toolbox, the data are input directly as multi-way arrays. Hence, there is no need for the DimX used earlier for defining the size of the array. If you have a 10x8x100 array, X, that is held in a 10x(8*100) matrix, i.e. the old matrix format, you can convert to a three-way array by X = reshape(X,10,8,100); This is the format in which the data must be input to the functions. MODEL OUTPUT Also the output has changed in most cases since version 1. With the use of cell arrays, it is much easier to handle the output of a varying number of component matrices. Let the components of a three-way parafac model is held in a cell e.g. called Factors; e.g. arising from the call of a four-component model Factors = parafac(X,3); Then the first

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值