matlab cell计算,MATLAB Cell数组 | 学步园
1)、要?jiǎng)h除單元數(shù)組中的行或列,可以用冒號(hào)表示單元數(shù)組中的行或列,然后對(duì)其賦一個(gè)空矩陣即可。
a={123,'abcde';zeros(3,5),ones(3,3)}
a =
[?????? 123]??? 'abcde'
[3x5 double]??? [3x3 double]
>> a(1,:)=[]
a =
[3x5 double]??? [3x3 double]
>> a={123,'abcde';zeros(3,5),ones(3,3)}
a =
[?????? 123]??? 'abcde'
[3x5 double]??? [3x3 double]
>> a{1}=[]
a =
[]??? 'abcde'
[3x5 double]??? [3x3 double]
>> a={123,'abcde';zeros(3,5),ones(3,3)}
a =
[?????? 123]??? 'abcde'
[3x5 double]??? [3x3 double]
>> a(1)=[]
a =
[3x5 double]??? 'abcde'??? [3x3 double]
>> a={123,'abcde';zeros(3,5),ones(3,3)}
a =
[?????? 123]??? 'abcde'
[3x5 double]??? [3x3 double]
>> a(2)=[]
a =
[123]??? 'abcde'??? [3x3 double]
2)、元寶數(shù)組和其他數(shù)組一樣,也可以通過(guò)reshape函數(shù)改變形狀,改變后的元胞數(shù)組與原元胞數(shù)組的元素個(gè)數(shù)相同,不能通過(guò)改變形狀來(lái)添加或刪除元胞數(shù)組中的元素。
a={123,'abcde';zeros(3,5),ones(3,3)}
a =
[?????? 123]??? 'abcde'
[3x5 double]??? [3x3 double]
>> size a
ans =
1???? 1
>> size(a)
ans =
2???? 2
>> b=reshape(a,1,4)
b =
[123]??? [3x5 double]??? 'abcde'??? [3x3 double]
>> size(b)
ans =
1????4
5、元胞數(shù)組中的操作函數(shù)cell:創(chuàng)建空的元胞數(shù)組cellfun:為元胞數(shù)組的每個(gè)元胞執(zhí)行指定的函數(shù)celldisp:顯示所有元胞的內(nèi)容cellplot:利用圖形方式顯示元胞數(shù)組cell2mat:將元胞數(shù)組轉(zhuǎn)變成為普通的矩陣mat2cell:將數(shù)值矩陣轉(zhuǎn)變成為元胞數(shù)組num2cell:將數(shù)值數(shù)組轉(zhuǎn)變成為元胞數(shù)組deal:將輸入?yún)?shù)賦值給輸出cell2struct:將元胞數(shù)組轉(zhuǎn)變成為結(jié)構(gòu)struct2cell:將結(jié)構(gòu)轉(zhuǎn)變?yōu)樵麛?shù)組iscell:判斷輸入是否為元胞數(shù)組
cellfun函數(shù)的主要功能是對(duì)元胞數(shù)組的元素(元胞)分別指定不同的函數(shù),不過(guò),能夠在cellfun函數(shù)中使用的函數(shù)ushuliang是有限的。能在cellfun中使用的函數(shù):isempty:若元胞元素為空,則返回邏輯真islogical:若元胞元素為邏輯類型,則返回邏輯真isreal:若元胞元素為實(shí)數(shù),則返回邏輯真length:元胞元素的長(zhǎng)ndims:元胞元素的維數(shù)prodofsize:元胞元素包含的元素個(gè)數(shù)
舉例:
a={123,'abcde';1-7i,ones(3,3)}
a =
[???????????? 123]??? 'abcde'
[1.0000 - 7.0000i]??? [3x3 double]
>> b=cellfun('isreal',a)
b =
1???? 1
0???? 1
>> c=cellfun('length',a)
c =
1???? 5
1???? 3
>> d=cellfun('isclass',a,'double')
d =
1???? 0
1???? 1
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的matlab cell计算,MATLAB Cell数组 | 学步园的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Linux 线程并发拷贝,【Linux】
- 下一篇: matlab安装m_map,MATLAB