finding the error between two curves from a fig
20 ビュー (過去 30 日間)
Takumi 2020 年 7 月 19 日
I used the findall function to find out what was plotted.
I noticed that some of the lines containing the NaN values were plotted as nonsense.
The lines you're trying to compare are probably h(2) and h(6).
In addition, the blue line contains NaN values that need to be removed.
Finally, we need to align the number of elements to compute the error, so we interpolate.
% get current axes
ax = gca;
% find object
h = findall(ax);
% get Y data of green and blue lines
GreenLineX = h(2).XData;
GreenLineY = h(2).YData;
BlueLineX = h(6).XData;
BlueLineY = h(6).YData;
% eliminate NaN
BlueLineX = rmmissing(BlueLineX);
BlueLineY = rmmissing(BlueLineY);
GreenLineY_interp = interp1(GreenLineX,GreenLineY,BlueLineX,'spline');
MeanSquaredError = mean((GreenLineY_interp - BlueLineY).^2);