필터 지우기
필터 지우기

How can I find the difference between two plots with a dimensional mismatch ?

조회 수: 2 (최근 30일)
Giorgos
Giorgos 2015년 8월 5일
편집: Giorgos 2015년 8월 5일
Hello all,
I have a question that I don't know if there is a solution off the bat.
Here it goes,
I have two data sets, that I have plotted on the same figure. I need to find their difference, simple so far... the problem arises in the fact that say matrix A has 1000 data points while the second (matrix B) has 580 data points. How will i be able to find the difference between the two graphs since their is a dimensional miss match between the two figures.
One way that I thought of is artificially inflating matrix B to 1000 data points, but the trend of the plot will remain the same. Would this be possible? and if yes how?

답변 (1개)

Walter Roberson
Walter Roberson 2015년 8월 5일
all_x = unique([x_from_A(:); x_from_B(:)]);
refined_A = interp1(x_from_A, A, all_x);
refined_B = interp1(x_from_B, B, all_x);
plot(all_x, refined_B - refined_A)
  댓글 수: 2
Giorgos
Giorgos 2015년 8월 5일
does this come with an explenation of what exactly the solution to my problem is?
THanks BTW :)
Giorgos
Giorgos 2015년 8월 5일
편집: Giorgos 2015년 8월 5일
Yeah I see what you did but extending the range of the matrix with NaN'S doesn't really work when you later whant to subtract them, take for example this code:
A=[1 2 3 4 5 ];
B=[11 22 33 44 55 66 77 88 99 1010];
Ya=A.*20+4;
Yb=B./10+3;
all_x = unique([A(:); B(:)])
refined_A = interp1(A, Ya, all_x);
refined_B = interp1(B, Yb, all_x);
C=refined_B - refined_A
plot(A,Ya,'r',B,Yb)
xlim([-100 1000])
grid on hold on
plot(all_x, C)
you will notice that the cells of C are filled with NaN's...
Do you have any suggestions on how to bypass this problem?

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

카테고리

Help CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by