Merge 2 fields in a structure

3 ビュー (過去 30 日間)
Tyler Murray
Tyler Murray 2016 年 9 月 6 日
コメント済み: Walter Roberson 2016 年 9 月 7 日
After I use importdata MATLAB splits up my data for some reason. The result is 2 fields within one structure, A.data is a 6000x9 double and A.textdata is a 6000x16 cell. The goal is to have one matrix 6000 x 25. Since they have the same number of rows I figured I could combine them using
A1 = [A.data, A.textdata];
however I get the error "Error using cat Dimension must be a real positive finite integer." I am unsure if it is because some of the cells contain strings.
A1 = {A.data{:}; A.textdata{:}};
did not work either.

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 9 月 7 日
[num2cell(A.data), A.textdata]
  2 件のコメント
Tyler Murray
Tyler Murray 2016 年 9 月 7 日
That does work. However when the new array appears, a 6000 x 25 cell, and I click on the variable to see the data only the first 16 columns show up. Any idea why?
Walter Roberson
Walter Roberson 2016 年 9 月 7 日
https://www.mathworks.com/matlabcentral/answers/288265-how-do-i-display-more-than-16-columns-of-a-cell-array

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by