フィルターのクリア

how to add and to remove cell arrays?

1 回表示 (過去 30 日間)
Audrey Mikari
Audrey Mikari 2022 年 7 月 13 日
回答済み: Jash Kadu 2022 年 7 月 13 日
how to repeat thse cell arrays and make it 10*2 cell arrays ? and how to extract line 2 and put it as line 6
Properties = 5×2 cell array
{'Aluminium'} {[ 780]}
{'Steel' } {[ 30]}
{'Titanium' } {[430]}
{'Copper' } {[ 300]}
{'Wood' } {[ 900]}

回答 (3 件)

Image Analyst
Image Analyst 2022 年 7 月 13 日
編集済み: Image Analyst 2022 年 7 月 13 日
Try this, if ca is your cell array:
ca = [ca;ca]

Voss
Voss 2022 年 7 月 13 日
Properties = { ...
'Aluminium' 780; ...
'Steel' 30; ...
'Titanium' 430; ...
'Copper' 300; ...
'Wood' 900; ...
}
Properties = 5×2 cell array
{'Aluminium'} {[780]} {'Steel' } {[ 30]} {'Titanium' } {[430]} {'Copper' } {[300]} {'Wood' } {[900]}
"how to repeat thse cell arrays and make it 10*2 cell arrays ?"
% maybe this
repmat(Properties,2,1)
ans = 10×2 cell array
{'Aluminium'} {[780]} {'Steel' } {[ 30]} {'Titanium' } {[430]} {'Copper' } {[300]} {'Wood' } {[900]} {'Aluminium'} {[780]} {'Steel' } {[ 30]} {'Titanium' } {[430]} {'Copper' } {[300]} {'Wood' } {[900]}
% or possibly this
repelem(Properties,2,1)
ans = 10×2 cell array
{'Aluminium'} {[780]} {'Aluminium'} {[780]} {'Steel' } {[ 30]} {'Steel' } {[ 30]} {'Titanium' } {[430]} {'Titanium' } {[430]} {'Copper' } {[300]} {'Copper' } {[300]} {'Wood' } {[900]} {'Wood' } {[900]}
"how to extract line 2 and put it as line 6"
% (operating on the original cell array Properties now)
Properties(6,:) = Properties(2,:)
Properties = 6×2 cell array
{'Aluminium'} {[780]} {'Steel' } {[ 30]} {'Titanium' } {[430]} {'Copper' } {[300]} {'Wood' } {[900]} {'Steel' } {[ 30]}

Jash Kadu
Jash Kadu 2022 年 7 月 13 日
Hi!
To generate properties Run in the command window:
Properties = {'Aluminium', 780 ; 'Steel' , 30; 'Titanium' , 430; 'Copper', 300; 'Wood' , 900}
To make it a 10x2 cell array just run
a = cat(1,Properties, Properties)
PFA the attached screenshot.

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by