Transform two vectors into a single one

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일

0 개 추천

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

manxino8
manxino8 2016년 3월 31일
편집: manxino8 2016년 3월 31일
It wouldn't work. What I really have is time in this format "2016-02-04 HH:MM:SS.FFF" I used timevec to separate the different fields and what I want now is HHMM (or HH:MM) to plot it against another field I have in another table (which has de same dimension)
Matthew Eicholtz
Matthew Eicholtz 2016년 3월 31일
Ok, it may be helpful to edit the original question to make this more clear.
Does this work?
s = datestr(now); %the current datestring as mm-ddd-yyyy HH:MM:SS
t = datestr(s,'HHMM'); %only the HHMM part

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

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

제품

질문:

2016년 3월 30일

댓글:

2016년 3월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by