Combine (overlap) two diffrent variables

조회 수: 1(최근 30일)
Carl Holmquist
Carl Holmquist 2021년 1월 25일
답변: Gaurav Garg 2021년 1월 28일
Hello!
need help to find overlap two diffrent variables (find where the values ar the same) xdate (180 values one row) and xdate_month (288 values on row). The two variables contain matlab numbers for date and starts and end with:
xdate: [NaN.....730867......735827.....NaN] ther are some NaN in the end and in the start
xdate_month: [726848.......735583] no NaN values.
When l have the overlapping values, x I can plot x with a y1 and y2 variables (y1 variables are observed gross primary production (GPP) values and y2 are modelled GPP on the same plot.
thanks in advance!
Carl
  댓글 수: 1
dpb
dpb 2021년 1월 25일
Look at
doc ismember
doc intersect
and friends...

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

답변(1개)

Gaurav Garg
Gaurav Garg 2021년 1월 28일
Hi Carl,
In addition to the functions mentioned (intersect and ismember), the following pseudo-code can be helpful -
for i=1:size(xdate):
for j=1:size(xdate_month):
if xdate(i) == xdate_month(j):
disp(xdata(i))
end
end
end

Community Treasure Hunt

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

Start Hunting!

Translated by