how i can combine two arrays which are in same dimension

1 次查看(过去 30 天)
date01 % array contains date and time like this '09/01/2015 00:30:00'
size(date01) =3565 1
press % array contains values of pressure like this 5.215
size(press) =3565 1
when i try to combine this two arrays in one matrices like
prm=[date01 press]
i got
error using horzcat
Dimensions of matrices being concatenated are not consistent
i need your help plz
thank you

采纳的回答

Star Strider
Star Strider 2018-3-8
You cannot combine string and numeric arrays in a numeric array.
You must use a cell array:
date_01 = '09/01/2015 00:30:00';
press = 5.215;
prm = {date_01 press}
prm =
1×2 cell array
{'09/01/2015 00:30:00'} {[5.2150e+000]}
This should work for your arrays as it did for these two scalars.
You can also combine them in a table.
  1 个评论
bishop Rab
bishop Rab 2018-3-9
Thanks,well i need this data in a matrix to use it after in plots or inside Matlab expressions,even with your suggestion it did not work for me.my data are in text file that contains date,time,and values...i'm really stuck in this pblm....the date and time is a serious issue for me

请先登录,再进行评论。

更多回答(1 个)

KSSV
KSSV 2018-3-8
use vertcat
  1 个评论
bishop Rab
bishop Rab 2018-3-8
did not work,the two arrays are the same size,when i use vertcat it gives me another array with one columns
prm=vertcat(data01 press)
size(prm)= 3566 1
i'm suppose to have a size like 3565 2, i need it in two columns

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by