Transform two vectors into a single one

1 回表示 (過去 30 日間)
manxino8
manxino8 2016 年 3 月 30 日
コメント済み: Matthew Eicholtz 2016 年 3 月 31 日
I have to vectors type double (each vector is a column vector with 4 rows):
A = [1; 2; 3; 4] B = [5; 6; 7; 8]
How do I transform these two vectors into a single one with the following form:
AB = [15; 26; 37; 48] (one column, 4 rows)
Thanks in advance!

回答 (1 件)

Matthew Eicholtz
Matthew Eicholtz 2016 年 3 月 30 日
Are all values of A and B integers? Do you know that all elements of A will be nonzero and that all elements of B will be less than 10?
If so, use
AB = 10*A+B;
  3 件のコメント
Matthew Eicholtz
Matthew Eicholtz 2016 年 3 月 31 日
Ok, it may be helpful to edit the original question to make this more clear.
Matthew Eicholtz
Matthew Eicholtz 2016 年 3 月 31 日
Does this work?
s = datestr(now); %the current datestring as mm-ddd-yyyy HH:MM:SS
t = datestr(s,'HHMM'); %only the HHMM part

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

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by