Calculating the distance/error between two graphs when the coordinates are given. Coordinates are not of equal size

A = [ 0 0
0.1000 0.3000
0.2000 0.6100
0.3000 0.9279
0.4000 1.2513
0.5000 1.5779
0.6000 1.9049
0.7000 2.2297
0.8000 2.5494
0.9000 2.8611
1.0000 3.1620
1.1000 3.4490
1.2000 3.7194
1.3000 3.9703
1.4000 4.1993
1.5000 4.4037]
B = [ 0 0
0.0000 0.0001
0.0000 0.0001
0.0001 0.0002
0.0001 0.0002
0.0002 0.0005
0.0002 0.0007
0.0003 0.0010
0.0004 0.0012
0.0008 0.0025
0.0012 0.0037
0.0017 0.0050
0.0021 0.0062
0.0042 0.0125
0.0063 0.0188
0.0084 0.0251
0.0104 0.0314
0.0209 0.0630
0.0314 0.0946
0.0418 0.1264
0.0523 0.1583
0.1046 0.3190
0.1570 0.4819
0.2093 0.6466
0.2616 0.8128
0.4366 1.3747
0.6115 1.9354
0.7865 2.4806
0.9614 2.9956
1.1873 3.5933
1.4133 4.0873]
% A is the estimation of B. I need to find the error between the observerd point of A and B. but the size of coordinates are not equal and x are not the same

 Accepted Answer

You can get A to the size of B using interpolation vice versa. Read about it.
% Get A to the size of B using interpolation
[m,n] = size(B) ;
Anew = zeros(m,n) ;
Anew(:,1) = linspace(min(A(:,1)),max(A(:,1)),m) ;
Anew(:,2) = interp1(A(:,1),A(:,2),Anew(:,1)) ;
Now Anew and B have same dimensions. You can dow hat you want.

3 Comments

Okay thank you very much!
but how can i measure the difference/approximate error between the two plots. the x-coordinates of both plots are not equal. Any idea? maybe you can metion the topic so I can read more about it
i mean if the x coordinates are equal, you can just use abs(Anew(:,2)-B(:,2)) to measure the error. but now it is not possible
You can use interp1 to have the same x coordinates. Try out.
% Get A to the size of A using interpolation
[m,n] = size(B) ;
Anew = zeros(m,n) ;
Anew(:,1) = B(:,1) ;
Anew(:,2) = interp1(A(:,1),A(:,2),Anew(:,1)) ;

Sign in to comment.

More Answers (0)

Asked:

N/A
on 5 Oct 2020

Edited:

on 5 Oct 2020

Community Treasure Hunt

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

Start Hunting!