vertcat for a number and string

조회 수: 1 (최근 30일)
Neesha
Neesha 2014년 9월 18일
편집: Adam 2014년 9월 18일
Hi All,
I have to metrices...
1)
SpecialName GenericName
1 457
2 555
3 758
Adding the image of my dataset copied over to excel. The column virtual and Product is giving me hard time for now.
2)
SpecialName GenericName
x NA
y NA
z NA
Now you can see both has the same column name but data type is different. The first one is Number and the 2nd one is string (when i see it shows each wrapped in ' ' hence saying it as string)
Now i want to do vertcat of those two. i trie applyign num2str on 1st one but still vertcat does not work. WHat should i do?
  댓글 수: 4
Adam
Adam 2014년 9월 18일
In that case I'm not too sure, I never even realised dataset existed as a type, although I see it is listed for possible removal in a future release.
If you have R2014a you should probably use the dataset2table function to convert to a table then you can use table operations for concatenation.
Image Analyst
Image Analyst 2014년 9월 18일
I like that answer, Adam. Put it below as an official answer. Tables are available for R2013b and later.

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

답변 (2개)

Adam
Adam 2014년 9월 18일
[ num2cell(a); b ]
should work if a and b are your two matrices and the first is a standard numeric array and the second is a cell array.
  댓글 수: 1
Neesha
Neesha 2014년 9월 18일
num2cell is not working , i mean it executes but vertcat fails, do you need any more info from me?

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


Adam
Adam 2014년 9월 18일
편집: Adam 2014년 9월 18일
If you have R2013b or later you should probably use the dataset2table function to convert to a table then you can use table operations for concatenation.

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by