How to find the difference between two graphs?

I have a graph shown in the figure below and now i have to find difference between two graphs, red line is drawn from some A= 59x2 matrix(taken from matlab Simulink) and blue line drawn from B= 149x2 matrix both drawn for same parameters and i don't have any idea how to find the difference between both the lines. So if anyone has any idea please help me with that.
code used is
figure();plot(simout.A.Time,simout.A.Data);
hold on;
plot(B(:,1),B(:,2));
Thanks in advance Agastya

 채택된 답변

the cyclist
the cyclist 2014년 11월 24일

3 개 추천

The curves are pretty smooth, so you could use the interp1 command to create y values at common x points for the two curves, and then take the differences of those y values.

댓글 수: 4

Agastya
Agastya 2014년 11월 24일
Hi, Can you just tell me the code with interp1 for my case?
This should give the y values for your two series, at x values of 0, 0.01, 0.02, ... 1.00
xq = 0 : 0.01 : 1;
yqA = interp1(simout.A.Time,simout.A.Data,xq);
yqB = interp1(B(:,1),B(:,2),xq);
Agastya
Agastya 2014년 11월 24일
Hi, Thank you very much
Hello the cyclist, what if the x values aren't common?Then how to find the difference?

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

추가 답변 (1개)

Ahmet Cecen
Ahmet Cecen 2014년 11월 24일

0 개 추천

One way is to interpolate the 59x2 matrix to be 149x2. Check spectral interpolation using Fourier transforms. You might even be able to get away with imresize in your case.

댓글 수: 1

Agastya
Agastya 2014년 11월 24일
Hi, Can you just tell me the code with interp1 for my case?

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

카테고리

도움말 센터File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by