How to get the error in two different curve ?

3 visualizaciones (últimos 30 días)
AnDau Xie
AnDau Xie el 22 de Ag. de 2018
Respondida: Raghava S N el 27 de Sept. de 2024
I have two data set , A1 and B1 are 151 datas ,and A2 and B2 are 98 datas(as the attached file Data.mat).
The image below are the two curves.
Because of the different number of these two data,I can't subtract each value directly.
Then,How do I get the error between them ?
----------------------The following steps are what I did.-----------------------
1. Using function 'saveas' to save these two image.Before saving these image, I had adjusted the X axis and Y axis in these two image to the same scale.
2. Using function 'imread' and 'rgb2gray' to read these two image and turn them into black and white graphics.
3. Using function 'imsubtract' to get the error between them.
------------------------------------------------------------------------------------------
There are some disadvantage in this way.
So I want to ask the better way to slove this problem.
Thank you so much !

Respuestas (1)

Raghava S N
Raghava S N el 27 de Sept. de 2024
Hi,
As the raw data is available in the form of matrices in the MAT-file, converting the plotted curves into images and then finding the error will not be necessary.
Up sampling the dataset with the lesser number of data points so that the datasets have the same lengths is the workaround to solve the issue of mismatched datasets. This is also discussed in the following MATLAB Answers post - https://www.mathworks.com/matlabcentral/answers/784166-interpolate-data-in-array-to-match-specified-length-of-data-in-another-vector.
The function “interp1” can be used to find the interpolated values of a “1-D” function at specific query points. With respect to your post, “A2” and “B2” have 98 data points whereas “A1” and “B1” have 151 data points. As a result, “A2” needs to be up sampled and the corresponding interpolated values should be found. This can be done as follows –
B2_interpolated = interp1(A2,B2,A1);
Here, “A2” is up sampled to the same length as “A1” and the corresponding interpolated values of “B2” are found. For more information about the “interp1” function, refer to this link - https://www.mathworks.com/help/matlab/ref/double.interp1.html.
Now, the two datasets can be subtracted from each other, as desired –
B1 – B2_interpolated;
Hope this helps!

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by