Help: "Error using horzcat, CAT arguments are not consistent"

So I have two data sets, a and b.
a = [1
2]
b = [20 30]
I used transpose to make b in a column as well...
x = a;
y = b';
[x,y]
However, when I try to use [x,y] it gives me the horzcat error.
I typed whos x y just to make sure they were the same size after transposing b, and sure enough:
>>whos x y
Name Size Bytes Class Attributes
x 2x1 126 cell
y 2x1 16 double
Given that they are both 2x1, I don't understand why I'm getting this error!
Any help would be appreciated. Thank you!

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 4 月 4 日

0 投票

Why does it say that x is cell rather than double? You must have done something else to "x".
Your difficulty has to do with the rules for concatenating cell arrays together with numeric arrays: basically if you want to concatenate together a cell array and a numeric array, the cell array must be a vector.

カテゴリ

製品

質問済み:

2013 年 4 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by