Re: Corelating data in Matlab. Finding the best fit



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
.



Relevant Pages

  • Corelating data in Matlab. Finding the best fit
    ... I want to write a code in Matlab, that will find a best fit. ... the best corelation between the RGB values and Temperature. ... Just pasting some raw data ... ...
    (comp.soft-sys.matlab)
  • fitting my data to a somewhat crazy function, any help/comments appreciated!
    ... I have some data that I am trying to fit to an equation, but am unsure ... each): Phase, Temperature, and Concentration. ... Is there anyway to use matlab to solve for my unknown constants: ...
    (comp.soft-sys.matlab)
  • Re: Newbie needs help
    ... Things like averaging the temperature at 12:30pm during the ... Started guide in the documentation. ... efficient use of MATLAB and avoid a lot of frustration if you gain at least ... Once you've gotten started in the "shallow end" of the MATLAB programming ...
    (comp.soft-sys.matlab)
  • Re: How to find this summation analytically?
    ... > ans = ... > Matlab refuses to compute symbolically the sum: ... elementary functions with these poles? ... the above function fsatisfies a functional equation ...
    (sci.math)
  • the moral of the story
    ... Turns out it has a negative temperature coefficient. ... The actual resistance of the material would have an ... So I decided to look at a kind of hyperboloid with three coefficients: ... This only leaves two coefficients to fit three data points, ...
    (sci.electronics.basics)