MATLAB Answers

0

Problem In curve fitting

Asked by Solmaz Kahourzade on 19 Jun 2018
Latest activity Commented on by Solmaz Kahourzade on 20 Jun 2018
Hello, I need to find a function for my data (TW2 and DatiOpt.PERDITE_FERRO) with minimum error. I tried "scatteredInterpolant" without any success. would you please help me to find the best fit for these sort of data? I appreciate your help.
load('TwMap_250Nm_cross saturation.mat');
[TP,VV]=meshgrid(DatiOpt.Tmap,DatiOpt.velmec);
figure(1);
TW2=(VV/1000).^2.*TP;
plot(TW2,DatiOpt.PERDITE_FERRO,'blue*','MarkerSize',2);
xlabel('Torque*Speed^2 [M Nm*(r/min)^2]', 'FontSize', 16);
ylabel('Iron Losses [W]', 'FontSize', 16);
grid on;
title('IPM: Motor Iron Losses', 'FontSize', 16);
figure(2);
f = scatteredInterpolant(TW2,DatiOpt.PERDITE_FERRO);
Loss=f(TW2);
plot(TW2,loss,'blue*','MarkerSize',2);

  2 Comments

KSSV
on 19 Jun 2018
What you want to fit?
Dear KSSV, If you plot figure 1, you see that there is a general trend between the TW2 and DatiOpt.PERDITE_FERRO. I wanted to find the nearest Polynomial function between TW2 and DatiOpt.PERDITE_FERRO that I can use for other inputs. However, base on John's answer, as my data are arbitrary, I can not find any function.
I appreciate if you have any solution.
Best Regards,

Sign in to comment.

1 Answer

Answer by John D'Errico
on 19 Jun 2018
 Accepted Answer

You won't find a function that fits any arbitrary, essentially scattered set of data. And that is what you seem to have.
Anyway, you do not seem to understand how to use scatteredInterpolant. Read the help.
F = scatteredInterpolant(X,v) creates an interpolant that fits a
surface of the form v = F(X) to the sample data set (X,v). The sample
points X must have size NPTS-by-2 in 2-D or NPTS-by-3 in 3-D, where
NPTS is the number of points. Each row of X contains the coordinates of
one sample point. The values v must be a column vector of length NPTS.
This is how you called scatteredInterpolant:
f = scatteredInterpolant(TW2,DatiOpt.PERDITE_FERRO);
However, TW2 is a 121x126 array, that is itself a function of two other variables.
So it is not at all clear what interpolation you are trying to achieve, what model you might want to see here.

  3 Comments

Dear John,
Thank you for your reply. I will seek other approaches now as I can not a function that fits any arbitrary data.
Any way, I wanted to find the nearest Polynomial function between TW2 and DatiOpt.PERDITE_FERRO as they follow a Polynomial function.
Regards,
The relationship that you want to be a "polynomial"
plot(TW2(:),DatiOpt.PERDITE_FERRO(:),'.')
Does not seem to be even close to a polynomial.
There is too much else happening in that relationship, due to other, ancillary variables that belies your claim. In fact, it is arguably rarely true that any relationship from the real world is truly a polynomial one, and even more rarely true when that relationship is pushed to its limits. Yes, I know of cases where a one can indeed show that a relationship should be, and in fact can be shown to be a true polynomial one. But most of the time, one must merely accept that a polynomial model provides a decent approximation.
In some cases, a polynomial can indeed be be a good approximation. But here? The "noise" in this relationship is really lack of fit, not noise, and that noise is clearly almost as important as the relationship between those two variables.
So, if you want a model for this process, then you need to return to the system that created it. Spend time deriving a model from first principles, one that is based on the theory of the process. But there is just way too much happening in this to claim a direct polynomial relationship.
Dear John,
Thank you. You are right. I will resolve it from the initial model.
Regards,

Sign in to comment.