Re: Corelating data in Matlab. Finding the best fit
- From: John D'Errico <woodchips@xxxxxxxxxxxxxxxx>
- Date: Wed, 01 Mar 2006 13:52:36 GMT
In article <ef2a83a.-1@xxxxxxxxxxxxxxxx>, "Snehaa Maun" <snehaa69@xxxxxxxxx> wrote:
Hi,
I want to write a code in Matlab, that will find a best fit. I have 4
columns of values. The Red, Green and blue values and in the fourth
column the temperature values. I want matlab to intelligently find me
the best corelation between the RGB values and Temperature. Any
pointers as to how i can go about doing this. Ofcourse the main goal
is to get the best fit with minimum error.
Thanks in advance.
Just pasting some raw data ...
Red Blue Green Temperature
corrcoef(RGBT)
ans =
1 0.99984 0.99162 0.8173
0.99984 1 0.99275 0.81253
0.99162 0.99275 1 0.78194
0.8173 0.81253 0.78194 1
The last column (or row) gives you the correlation
coefficient between each of {R,G,B} with T.
If you want a simple regression model, then \ will do it.
More complex models are easily enough built using \, or
with polyfitn. (Find it on the file exchange.)
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=10065&objectType=FILE
RGBT(:,1:3)\RGBT(:,4)
ans =
30.272
-27.979
0.37274
polyfitn(RGBT(:,1:3),RGBT(:,4),'constant x y z')
ans =
ModelTerms: [4x3 double]
Coefficients: [978.81 7.8368 -6.4549 -0.75223]
ParameterVar: [804.67 1.8815 1.943 0.089155]
ParameterStd: [28.367 1.3717 1.3939 0.29859]
R2: 0.74369
RMSE: 272.56
VarNames: {'x' 'y' 'z'}
Or, you can use regress or stepwise from the statistics
toolbox, if you have that TB.
HTH,
John D'Errico
--
The best material model of a cat is another, or preferably the same, cat.
A. Rosenblueth, Philosophy of Science, 1945
Those who can't laugh at themselves leave the job to others.
Anonymous
.
- References:
- Corelating data in Matlab. Finding the best fit
- From: Snehaa Maun
- Corelating data in Matlab. Finding the best fit
- Prev by Date: Creating Matrix with Chars
- Next by Date: Re: .wav file - BPM Detection, please enlighten me!
- Previous by thread: Corelating data in Matlab. Finding the best fit
- Next by thread: Re: Memory allocation error
- Index(es):
Relevant Pages
|