当前位置:网站首页>【matlab】matlab中变量赋值函数deal
【matlab】matlab中变量赋值函数deal
2022-08-08 05:23:00 【后厂村路蔡徐坤】
在matlab中,变量赋值可以使用等号直接赋值,如:
% 直接赋值
a=2;
a=1.236;
a="abc";
a='a';
a= [1,2,3,4,5,6];
但是,程序涉及多变量的时候,直接赋值的方式显得非常麻烦。matlab中deal函数可用于:处理一赋多或者多赋多变量赋值的场景。
一、语法
[Y1, Y2, Y3, ...] = deal(X)
[Y1, Y2, Y3, ...] = deal(X1, X2, X3, ...)
[S.field] = deal(X)
[X{
:}] = deal(A.field)
[Y1, Y2, Y3, ...] = deal(X{
:})
[Y1, Y2, Y3, ...] = deal(S.field)
二、说明
[Y1, Y2, Y3, …] = deal(X) 将单一输入复制到请求的所有输出。它与 Y1 = X、Y2 = X、Y3 = X、… 相同
[Y1, Y2, Y3, …] = deal(X1, X2, X3, …) 与 Y1 = X1、Y2 = X2、Y3 = X3、 … 相同
三、示例
示例1:变量一赋多
[Y1, Y2, Y3, ...] = deal(1)
%Y1=Y2=....Yn=1
示例2:变量多赋多
[Y1, Y2, Y3, ...] = deal(1,3,2, ...)
%等价于:Y1=1;Y2=3;Y3=2....
示例3:矩阵多赋多
C = {
rand(3) ones(3,1) eye(3) zeros(3,1)};
[a,b,c,d] = deal(C{
:})
a =
0.9501 0.4860 0.4565
0.2311 0.8913 0.0185
0.6068 0.7621 0.8214
b =
1
1
1
c =
1 0 0
0 1 0
0 0 1
d =
0
0
0
边栏推荐
- C language - function
- y90. Chapter 6 Microservices, Service Grids and Envoy Combat -- Service Grid Basics (1)
- C语言力扣第58题之最后一个单词的长度。从后往前遍历
- 【猜拳游戏 基于Objective-C语言】
- Error: [Intervention] Unable to preventDefault inside passive event listener due to target ...
- 使用ffmpeg解码音频sdl(push)播放
- 硬盘基础知识
- Open3D ICP精配准(使用鲁棒性核函数)
- The difference between CHAR_LENGTH() and LENGTH() in MySQL
- OLTP和OLAP问题的个人总结
猜你喜欢
随机推荐
11-golang流程控制
14.Unity2D 横版 粒子系统特效 飙血粒子+高处落地粒子+对象池管理所有粒子
Leetcode78. 子集
sqlmap+dnslog注入复现
C language force to deduct the length of the last word of the 58th question.Traverse from back to front
ES6剩余参数的使用
MYSQL导出数据字典
gcc/g++使用
MYSQL export data dictionary
温故知新—Activity的五种启动模式
邮件钓鱼上线cobalstrike
Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:]
BMS 产品功能和详细设计规格
《动机与人格》笔记(一)——人类似乎从来就没有长久地感到过心满意足
MySQL4 (multi-table query)
Hundreds of billions, large-scale: performance tuning practice of Tencent's super-large Apache Pulsar cluster
RecycleView配合Adapter调用notifyDataSetChanged闪屏?
C language - function
Building a High-Performance Platform on AWS Using Presto and Alluxio to Support Real-Time Gaming Services
字符串题目解析









