当前位置:网站首页>元胞数组处理
元胞数组处理
2022-07-23 16:25:00 【jk_101】
目录
将元胞添加到元胞数组
此示例演示了如何将元胞添加到元胞数组。创建一个 1×3 元胞数组。
C = {1, 2, 3}
C=1×3 cell array
{[1]} {[2]} {[3]}将数据分配给当前维度之外的元胞。MATLAB 将元胞数组扩展到包括指定下标的矩形。任何中间元胞都包含空数组。
C{4,4} = 44
C=4×4 cell array
{[ 1]} {[ 2]} {[ 3]} {0x0 double}
{0x0 double} {0x0 double} {0x0 double} {0x0 double}
{0x0 double} {0x0 double} {0x0 double} {0x0 double}
{0x0 double} {0x0 double} {0x0 double} {[ 44]}
通过将一个空数组指定为元胞的内容来添加元胞而不指定值。C 现在是一个 5×5 元胞数组。
C{5,5} = []
C=5×5 cell array
Columns 1 through 4
{[ 1]} {[ 2]} {[ 3]} {0x0 double}
{0x0 double} {0x0 double} {0x0 double} {0x0 double}
{0x0 double} {0x0 double} {0x0 double} {0x0 double}
{0x0 double} {0x0 double} {0x0 double} {[ 44]}
{0x0 double} {0x0 double} {0x0 double} {0x0 double}
Column 5
{0x0 double}
{0x0 double}
{0x0 double}
{0x0 double}
{0x0 double}
合并元胞数组
此示例演示了如何通过串联或嵌套来合并元胞数组。为了运行此示例中的代码,使用相同数量的列创建多个元胞数组:
C1 = {1, 2, 3};
C2 = {'A', 'B', 'C'};
C3 = {10, 20, 30};使用数组串联运算符 [] 串联元胞数组。在此示例中,通过使用分号分隔元胞数组来垂直串联元胞数组:
C4 = [C1; C2; C3]C4 是一个 3×3 元胞数组:
C4 =
[ 1] [ 2] [ 3]
'A' 'B' 'C'
[10] [20] [30]使用元胞数组构造运算符 {} 创建一个嵌套元胞数组:
C5 = {C1; C2; C3}C5 是一个 3×1 元胞数组,其中每个元胞都包含一个元胞数组:
C5 =
{1x3 cell}
{1x3 cell}
{1x3 cell}要将字符向量元胞数组合并到一个字符向量中,使用 strjoin 函数。
删除元胞数组中的数据
此示例演示了如何删除单个元胞中的数据,以及如何删除元胞数组中的全部元胞。创建一个 3×3 元胞数组
C = {1, 2, 3; 4, 5, 6; 7, 8, 9}
C=3×3 cell array
{[1]} {[2]} {[3]}
{[4]} {[5]} {[6]}
{[7]} {[8]} {[9]}通过将一个空数组赋给元胞并使用花括号建立内容索引 {} 来删除特定元胞的内容。
C{2,2} = []
C=3×3 cell array
{[1]} {[ 2]} {[3]}
{[4]} {0x0 double} {[6]}
{[7]} {[ 8]} {[9]}
通过使用圆括号 () 建立的标准数组索引来删除元胞集。例如,删除 C 的第二行。
C(2,:) = []
C=2×3 cell array
{[1]} {[2]} {[3]}
{[7]} {[8]} {[9]}
合并元胞数组与非元胞数组
合并多个数组时,若其中有一个或多个为元胞数组,将返回一个新元胞数组。每个原始数组占用新数组中的一个元胞:
A = [100, {uint8(200), 300}, 'MATLAB'];
whos A
Name Size Bytes Class Attributes
A 1x4 477 cell合并的数组中的每个元素都保持其原始类:
fprintf('Classes: %s %s %s %s\n',...
class(A{1}),class(A{2}),class(A{3}),class(A{4}))
Classes: double uint8 double char边栏推荐
- Interviewer: what do you think is your biggest weakness?
- 入门学习3D建模一般会遇到哪些问题?实在是太多了
- 大神“魔改”AirPods,配备USB-C接口,3D打印外壳让维修更容易
- JVM – 彻底理解打破双亲委派机制
- 关于分组查询的一道sql题
- @Entity 里面的 JPA 注解
- deepstream学习笔记(二):gstreamer与deepstream-test1说明
- 使用 Three.js 实现'雪糕'地球,让地球也凉爽一夏
- PCL: multi line fitting (RANSAC)
- How does memory alignment in go optimize program efficiency?
猜你喜欢

类的基础
![[toggle 30 days of ML] Diabetes genetic risk detection challenge (2)](/img/39/d0134a8493877beaa6b6850c045f2b.png)
[toggle 30 days of ML] Diabetes genetic risk detection challenge (2)

Deep learning learning record - update of learning rate of optimizer

【JZOF】13機器人的運動範圍

Can self-study 3D modeling succeed? Can self-study lead to employment?

rhcsa笔记七

20220721 积分环节的时频域分析

How the lock issued by go works (combined with the source code)

Simply understand why the first EVM equivalent zkevm polygon is fully betting

错误“ Failed to fetch “xxx”Temporary failure resolvingW: Some index files failed to download“解决办法
随机推荐
Great God "magic change" airpods, equipped with usb-c interface, 3D printing shell makes maintenance easier
C language · structure (Introduction to linear table)
我的创作纪念日
Problems and methods of creating multiple projects under one solution in VS2010
如何理解:普通代码块、构造块、静态块?有什么关系?
字符串长度函数strlen()。。字符串函数头文件string.h「建议收藏」
使用 Three.js 实现'雪糕'地球,让地球也凉爽一夏
Detailed explanation of common curl commands and parameters
栈/堆/队列刷题(中)
vb连接Access数据库自定义
类的基础
Ubuntu 22.04 installing mysql8
如何评估券商分析师预测股票涨跌的准确性?
[sharing game modeling model making skills] how ZBrush adjusts the brush size
Modeling just learning is very confused. How to learn the next generation role modeling process?
华为胖瘦AP切换方法
Flame Graphs 火焰图安装与使用
Alliance DAO创始人:100+Web3基础设施及Dapp创业清单
大佬在线复盘:我在训练 DALL·E 时犯过的错
awk从入门到入土(16)awk综合案例