Comparison of two Vektors with different size to find variables

4 ビュー (過去 30 日間)
Josef Bubendorfer
Josef Bubendorfer 2019 年 11 月 13 日
コメント済み: Walter Roberson 2019 年 11 月 13 日
I have a problem with my read measurement datas.
A vector has a not quite continuous time series of 15 minutes values ​​for a period of 7 years. The second vector or matrix has a continuous (precipitation) time series of 15 minutes values. I have already tried a few things, but I can not come up with a solution to get a vector with the precipitation values ​​corresponding to the "correct" date from the first vector.
An example of my problem:
a = [731947,312500000
731947,322916667
731947,333333333
731947,364583333
731947,375000000
731947,395833333
731947,406250000]
b = [731947,312500000 2
731947,322916667 5
731947,333333333 6
731947,343750000 8
731947,354166667 2
731947,364583333 0
731947,375000000 0
731947,385416667 0
731947,395833333 0
731947,406250000 0]
c= [731947,312500000 2 %This should be the result.
731947,322916667 5
731947,333333333 6
731947,364583333 0
731947,375000000 0
731947,395833333 0
731947,406250000 0]

採用された回答

James Tursa
James Tursa 2019 年 11 月 13 日
編集済み: James Tursa 2019 年 11 月 13 日
E.g.,
x = ismember(b(:,1:2),a(:,1:2),'rows');
c = b(x,:);
Depending on how the times were constructed, you might need to use ismembertol( ).
  3 件のコメント
Josef Bubendorfer
Josef Bubendorfer 2019 年 11 月 13 日
編集済み: Josef Bubendorfer 2019 年 11 月 13 日
x = ismember(b(:,1:2),a(:,1:2),'rows');
c = b(x,:);
Thanks for the fast answer. I had to bring the Vektors to same size (with zeros) and then it was working.
Walter Roberson
Walter Roberson 2019 年 11 月 13 日
The notation you used for the data was ambiguous. We could not tell whether you had two columns in a or if you were using comma to represent decimal point. But you talked a as being a vector and you show space as a column separator for b, so the evidence is that you are using comma as decimal, but your code is what would be expected if you are using two columns to represent the time instead of comma as decimal indicator.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDenoising and Compression についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by