フィルターのクリア

How Can I union four non-equal size vector in matlab?

2 ビュー (過去 30 日間)
Jamal
Jamal 2013 年 11 月 17 日
コメント済み: Jamal 2013 年 11 月 17 日
Hi I want to write Finite element MATLAB code. I want to union 4 vectors that they are different in their sizes. I used "unique" command, however; My program has this Error:
"Error using horzcat Dimensions of matrices being concatenated are not consistent."

採用された回答

Andrei Bobrov
Andrei Bobrov 2013 年 11 月 17 日
A=[1 2 3 4 5];
B=[7 4 5];
C=unique([A(:);B(:)])
  1 件のコメント
Jamal
Jamal 2013 年 11 月 17 日
thank u very much.

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

その他の回答 (1 件)

Mohammad Monfared
Mohammad Monfared 2013 年 11 月 17 日
To union two vectors they should be of the same kind, row vectors or column vectors.
if they are row vectors;
v=[v1, v2];
if they are column vectors:
v=[v1; v2];
  3 件のコメント
Mohammad Monfared
Mohammad Monfared 2013 年 11 月 17 日
編集済み: Mohammad Monfared 2013 年 11 月 17 日
In this case size does not matter and you can switch between column and row vector as:
v=v' ;
two additional functions are also available which are isrow() and iscolumn(). They are useful when you don't know if a vector is in row or column shape.
Jamal
Jamal 2013 年 11 月 17 日
for Example: A=[1 2 3 4 5] B=[7 4 5] union array that I want C=[1 2 3 4 5 7]
C=unique([A,B])
however, I received Error from Matlab, because they are not consistent.

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

カテゴリ

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