Prev: Client Server implemtation for image transfer
Next: Default command for fitting of distributions like gamma
From: fab Fabritius on 10 Jun 2010 00:55 Hi, first of all thank you all for your passions while I`m trying to explain my problem with my poor knowledge of matlab. I have two different sized data files. The first file or data matrice, let`s call it A, has four columns. First column is for time in hours and the three next are some measurement data in number form. The second matrice (B) has two columns, first column is again for time in hours and the second column is for velocity of the measuring device. What I wanna do is to combine A and B into one data file (C) that has starting from the left - time in hours, three columns for measurement data from file A and fifth column for velocity from B. Now my problem is that A and B have different time series (The other one starts earlier, and the other one has some gaps in the time serie). I want to find the values from A and B that have the same time and take only this data into matrice C. I`ve tried some for loops to do this, and also I`ve tried using isequal, but I just dont get it work at the moment. If you have any tips for me, they are appreciated. best regards taneli
From: Oleg Komarov on 10 Jun 2010 04:01 "fab Fabritius" <hupr7o$6md$1(a)fred.mathworks.com>... > Hi, > first of all thank you all for your passions while I`m trying to explain my problem with my poor knowledge of matlab. > > I have two different sized data files. The first file or data matrice, let`s call it A, has four columns. First column is for time in hours and the three next are some measurement data in number form. The second matrice (B) has two columns, first column is again for time in hours and the second column is for velocity of the measuring device. > > What I wanna do is to combine A and B into one data file (C) that has starting from the left - time in hours, three columns for measurement data from file A and fifth column for velocity from B. Now my problem is that A and B have different time series (The other one starts earlier, and the other one has some gaps in the time serie). > > I want to find the values from A and B that have the same time and take only this data into matrice C. I`ve tried some for loops to do this, and also I`ve tried using isequal, but I just dont get it work at the moment. If you have any tips for me, they are appreciated. > > best regards > taneli Use intersect to find common dates between A and B. After that you'll have the indices that will tell which rows of A and B to take into the new matrix C. Example: A = [(1:100).' rand(100,1)]; B = [([23:50 60:131]).' rand(100,1)]; [intersection,a,b] = intersect(A(:,1),B(:,1)); C = [A(a,:),B(b,end)];
From: fab Fabritius on 10 Jun 2010 05:50
"Oleg Komarov" <oleg.komarovRemove.this(a)hotmail.it> wrote in message <huq644$j28$1(a)fred.mathworks.com>... > "fab Fabritius" <hupr7o$6md$1(a)fred.mathworks.com>... > > Hi, > > first of all thank you all for your passions while I`m trying to explain my problem with my poor knowledge of matlab. > > > > I have two different sized data files. The first file or data matrice, let`s call it A, has four columns. First column is for time in hours and the three next are some measurement data in number form. The second matrice (B) has two columns, first column is again for time in hours and the second column is for velocity of the measuring device. > > > > What I wanna do is to combine A and B into one data file (C) that has starting from the left - time in hours, three columns for measurement data from file A and fifth column for velocity from B. Now my problem is that A and B have different time series (The other one starts earlier, and the other one has some gaps in the time serie). > > > > I want to find the values from A and B that have the same time and take only this data into matrice C. I`ve tried some for loops to do this, and also I`ve tried using isequal, but I just dont get it work at the moment. If you have any tips for me, they are appreciated. > > > > best regards > > taneli > > Use intersect to find common dates between A and B. > After that you'll have the indices that will tell which rows of A and B to take into the new matrix C. > > Example: > A = [(1:100).' rand(100,1)]; > B = [([23:50 60:131]).' rand(100,1)]; > > [intersection,a,b] = intersect(A(:,1),B(:,1)); > C = [A(a,:),B(b,end)]; Thank you, this was just what I was looking for! Now it works! -taneli |