how to add and to remove cell arrays?
    조회 수: 5 (최근 30일)
  
       이전 댓글 표시
    
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]}
댓글 수: 0
답변 (3개)
  Image Analyst
      
      
 2022년 7월 13일
        
      편집: Image Analyst
      
      
 2022년 7월 13일
  
      Try this, if ca is your cell array:
ca = [ca;ca]
댓글 수: 0
  Voss
      
      
 2022년 7월 13일
        Properties = { ...
    '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)
% or possibly this
repelem(Properties,2,1)
"how to extract line 2 and put it as line 6"
% (operating on the original cell array Properties now)
Properties(6,:) = Properties(2,:)
댓글 수: 0
  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. 
Also check the concatenate array documentation to learn more : https://www.mathworks.com/help/matlab/ref/double.cat.html#mw_43eb23a4-8e47-434a-a0ce-36c64539934a
댓글 수: 0
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!