creating an empty cell

조회 수: 3 (최근 30일)
Jason
Jason 2011년 4월 4일
댓글: Zeeshan Ahmad Khalil 2018년 3월 28일
I have two matrix:
A = [1 2 3]
B = [4 5 6 7; 9 8 7 6; 5 4 3 2]
I want to combine these two matrice into:
C = [ 1 2 3; 4 5 6 7; 9 8 7 6; 5 4 3 2]
I want the top left corner to be an empty cell because in the end I want to write matrix C to a csv file so I would like to have that cell empty. I tried playing around with vertcat and horzcat but I keep getting dimensions are not consistent error.
  댓글 수: 1
Sean de Wolski
Sean de Wolski 2011년 4월 4일
Well written question; you get a vote!

댓글을 달려면 로그인하십시오.

채택된 답변

Sean de Wolski
Sean de Wolski 2011년 4월 4일
Fill it with a Nan:
C = [[A, nan];B];
  댓글 수: 2
Jason
Jason 2011년 4월 4일
This answer will do for what I am doing but it would be nice to have an empty blank cell instead.
Zeeshan Ahmad Khalil
Zeeshan Ahmad Khalil 2018년 3월 28일
i also want to keep a cell blank so that when i concatenate it with the other cells it will be removed automatically.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Andrew Newell
Andrew Newell 2011년 4월 4일
dlmwrite('myfile.csv',A,'coffset',1)
dlmwrite('myfile.csv',B,'-append')
  댓글 수: 1
Jason
Jason 2011년 4월 4일
perfect!

댓글을 달려면 로그인하십시오.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by