Hi all,
I'm creating some code to help me read in some probe results from a machine and analyse the repeatably and variability.
I've attached the sample data and files I'm using. I can get everything to work except I'm missing something with the residuals.
I can plot the residuals vs the zero line on the graph but I'm unable to then use that data. I want to plot on that graph the minimum and maximum residual (like I'v done on the other figures) and also use the difference between the two in the title string to give me the total variation (in a perfect world with no machine temperature variation).
I hope you can help.
PS - Area of help required is
xxk = plot( Facedata, v1, face,'residuals');
How do I get the data from "residuals"?

 Réponse acceptée

Thorsten
Thorsten le 21 Jan 2015
Modifié(e) : Thorsten le 21 Jan 2015
The is no space between adjust and the following number in your Locator Repeatability 131 No Coolant.txt file, resulting in Adjust being all NaN. If you add the space everything should run smoothly.
I am not aware of a 'residuals' parameter to the Matlab's plot function. What should work is
plot( v1, face - Facedata);
BTW: naming the fitted data Facedata might be a bit missleading; use, e.g., face_fitted instead.

3 commentaires

with regards to the no space - In my function to inport I use t (as in the t at the end of adjust) as a deliminator
%%Initialize variables.
delimiter = {' ','t'};
if nargin<=2
startRow = 1;
endRow = inf;
end
I don't know if you noticed this.
I don't get any NaN.
With regards to using plot(v1, face - facedata), this returns:
Undefined function 'minus' for input arguments of type 'cfit'.
Error in Locator1 (line 132)
plot (v1,face-face_fit);
As you can see I renamed it at your suggestion.
Any further help?
Thorsten
Thorsten le 21 Jan 2015
Modifié(e) : Thorsten le 21 Jan 2015
Oh, that escaped my notice; I have an older version of Matlab that's not supporting multiple delimiters, so I had to change that.
I do have a "fit" function but that is probably NOT the one you are using: mine in the stats TB and does not run with your input
>> which fit
C:\Program Files\MATLAB\R2007b\toolbox\stats\@gmdistribution\fit.m % gmdistribution method
And which plot do you use? It's probably not the build-in that I use
>> which plot
built-in (C:\Program Files\MATLAB\R2007b\toolbox\matlab\graph2d\plot)
I used polyfit for fitting as follows (altough Matlab complains, the fit looks good):
p = polyfit(v1, face, 5);
Warning: Polynomial is badly conditioned. Add points with distinct X
values, reduce the degree of the polynomial, or try centering
and scaling as described in HELP POLYFIT.
face_fitted = polyval(p, v1);
Have a look at the fit:
plot(v1, face, 'b', v1, face_fitted, 'r')
and at the residuals:
stem(face - face_fitted)
Can you run this code?
Maybe you use some different versions of plot and fit that generate the trouble. If so, please provide these functions.
Many thanks for your help. I've been through the examples and believe I have solved it.
The bit I was missing is that
[face_fit, gof] = fit( v1,face, 'poly5', 'Normalize', 'on' );
Returns the function face_fit which is the polynomial as in p5*x^5 etc etc.
So I then had to use it as such to create a new variable that is the line:
fit_line = face_fit(v1);
Then I could subtract my vaules from that line to give me the residuals.
resid = face - fit_line;
It's a shame this isn't built into Matlab but heh, you can't have everything!
Many thanks for your help.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by