0

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..

(Have pasted some raw data if that would help)

Red Blue Green Temp.

17 13 28 380
15 10 28 386
25 14 40 392
17 13 38 398
9 8 23 404
3 2 7 411
7 9 19 418
10 12 21 426
3 4 13 434
0 0 6 442
4 6 19 450
6 7 19 459
7 6 14 468
1 1 3 477
6 4 7 487
19 17 22 497
3 2 6 507
3 4 11 518
6 6 20 528
4 5 22 539
3 4 20 551
2 2 16 562
13 10 35 574
25 19 49 586
19 12 31 598
12 7 18 611
14 10 25 623
20 14 33 636
19 13 36 650
13 6 29 663
18 7 30 677
7 3 17 690
14 7 33 704
8 4 30 718
15 10 44 733
17 13 50 747
13 11 35 762
17 16 31 777
11 12 20 792
7 7 10 807
6 5 7 823
4 3 4 838
4 4 7 854
0 1 2 870
0 3 12 886
6 12 36 902
5 9 33 918
1 2 25 935
4 5 31 951
9 10 42 968
7 7 30 985
1 0 11 1002
3 3 18 1018
5 6 18 1036
6 10 21 1053
6 9 15 1070
11 13 19 1087
7 7 11 1105
9 9 21 1122
21 19 44 1140
22 22 49 1157
6 7 29 1175
3 6 22 1193
13 18 33 1210
13 19 34 1228
5 9 21 1246
9 8 19 1264
12 10 23 1282
10 8 21 1300
13 11 29 1317
11 10 31 1335
22 23 58 1353
25 28 57 1371
37 42 67 1389
31 37 42 1407
29 31 25 1425
47 47 32 1443
66 65 37 1461
78 75 41 1479
88 83 42 1497
126 116 62 1514
163 155 83 1532
175 168 87 1550
190 183 96 1568
240 231 118 1585
286 275 139 1603
334 320 167 1620
389 372 193 1638
443 426 213 1655
492 471 228 1672
558 538 244 1689
628 608 269 1707
723 706 324 1724
805 790 377 1740
887 875 426 1757
959 959 485 1774
1029 1041 512 1790
1116 1137 545 1807
1203 1234 591 1823
1294 1331 631 1839
1392 1434 716 1855
1465 1522 786 1871
1529 1599 848 1887
1609 1684 919 1903
1692 1775 1002 1918
1770 1850 1070 1933
1853 1911 1124 1949
1906 1973 1185 1964
1967 2044 1254 1978
2031 2117 1324 1993
2072 2185 1352 2007
2114 2232 1401 2022
2158 2279 1462 2036
2225 2327 1518 2050
2260 2371 1568 2063
2294 2412 1607 2077
2322 2447 1640 2090
2353 2482 1670 2103
2382 2514 1700 2116
2397 2538 1722 2128
2411 2561 1755 2141
2433 2588 1795 2153
2447 2601 1810 2165
2467 2613 1811 2176
2480 2617 1781 2188
2469 2611 1744 2199
2463 2612 1763 2209
2472 2621 1799 2220
2471 2617 1803 2170
2471 2610 1792 2164
2463 2596 1768 2157
2436 2572 1729 2149
2410 2549 1694 2140
2401 2533 1673 2131
2389 2516 1652 2121
2348 2483 1620 2110
2297 2441 1586 2099
2260 2403 1556 2087
2228 2365 1526 2075
2206 2331 1499 2062
2179 2292 1465 2049
2113 2245 1437 2036
2074 2173 1387 2022
2019 2113 1313 2008
1947 2040 1228 1994
1882 1977 1159 1980
1822 1919 1135 1966
1756 1862 1129 1952
1713 1809 1102 1937
1669 1762 1084 1923
1593 1685 1006 1909
1528 1623 940 1895
1469 1568 890 1881
1414 1508 840 1867
1355 1446 804 1853
1297 1382 766 1839
1234 1313 713 1826
1180 1257 674 1812
1149 1223 647 1799
1097 1163 603 1786
1041 1098 551 1773
1000 1047 514 1761
952 991 475 1748
900 937 438 1736
855 889 410 1724
811 842 387 1713
768 799 377 1701
721 752 364 1690
661 691 347 1680
624 646 334 1669
587 599 307 1659
558 559 287 1649
551 542 279 1639
527 516 269 1629
493 480 249 1620
466 453 233 1611
434 424 213 1602
418 402 205 1594
396 378 196 1586
374 354 189 1577
355 339 183 1570
326 315 168 1562
301 292 154 1555
316 309 164 1547
276 271 144 1540
255 250 135 1533
261 254 151 1527
262 252 166 1520
239 228 161 1514
229 214 162 1508
231 214 175 1502
230 211 189 1496
204 184 168 1490
181 163 155 1484
181 165 143 1479
161 149 117 1474
155 147 111 1468
147 145 103 1463
132 133 98 1458
122 124 95 1453
118 121 97 1448
122 122 103 1443
116 113 98 1438
109 101 92 1433
105 94 86 1428
87 76 70 1423
95 82 76 1418
93 82 74 1414
84 75 58 1409
77 74 47 1404
75 76 44 1399
74 78 41 1394
63 69 41 1390
43 50 36 1385
35 44 41 1380
38 49 60 1375
44 55 61 1370
49 59 60 1365
45 53 44 1360
35 41 28 1355
31 36 26 1350
39 43 34 1345
43 45 41 1340
42 43 46 1335
46 45 54 1330
26 25 37 1324
26 23 36 1319
43 43 59 1314
35 39 49 1309
24 31 34 1303
28 38 34 1298
27 37 29 1292
24 33 28 1287
21 30 31 1281
22 31 38 1276
27 34 52 1270
29 35 59 1265
36 44 75 1259
32 39 66 1254
35 44 65 1248
18 26 39 1243
20 25 32 1237
25 26 38 1232
33 33 50 1226
22 21 44 1221
14 14 40 1216
23 23 55 1210
33 35 73 1205
28 33 73 1200
20 26 67 1195
21 31 71 1189
28 32 72 1184
20 22 55 1179
11 13 38 1174
17 15 42 1170
22 26 59 1165
17 24 51 1160
23 33 59 1156
17 27 40 1151
21 31 37 1147
19 25 28 1143
21 26 27 1139
18 22 26 1135
19 25 34 1131
21 29 44 1128
20 28 54 1124
14 25 49 1121
12 21 46 1117
9 18 39 1114
2 10 27 1111
6 14 35 1108
10 20 41 1106
10 23 45 1103
12 26 48 1101
10 25 49 1098
8 23 47 1096
5 19 44 1094
5 15 41 1092
10 26 46 1090
22 39 55 1088
18 28 35 1087
12 19 20 1085
25 31 33 1083
33 38 39 1082
37 42 48 1080
15 21 33 1079
19 27 41 1077
13 23 39 1075
9 20 27 1074
6 16 17 1072
12 25 22 1070
18 28 21 1068
14 19 18 1066
15 15 18 1063
18 17 26 1060
12 13 28 1058
15 17 37 1054
27 30 57 1050
22 26 53 1050
14 19 44 1054
15 21 46 1057
20 25 49 1060
22 29 51 1063
35 40 58 1066
28 33 41 1068
25 27 30 1070
16 18 18 1072
16 20 18 1074
25 31 27 1075
23 30 29 1077
21 29 34 1079
25 30 40 1080
28 29 46 1082
25 23 45 1083
28 24 42 1085
28 27 41 1087
30 31 42 1088
2 4 8 1090
16 20 26 1092
27 37 43 1094
21 34 46 1096
11 20 41 1098
10 20 37 1101
15 26 41 1103
16 25 28 1106
4 10 9 1108
5 13 14 1111
2 6 9 1114
7 15 21 1117
36 46 63 1120
10 15 21 1124
4 7 9 1127
10 14 12 1131
27 31 22 1135
20 25 18 1139
15 21 15 1143
19 25 23 1147
29 34 37 1151
29 31 40 1156
14 15 30 1160
17 19 38 1165
24 27 57 1169
22 28 61 1174
34 41 80 1179
29 38 75 1184
26 34 67 1189
20 28 58 1194
18 23 52 1199
24 28 56 1205
35 40 71 1210
31 33 51 1215
28 26 37 1221
27 22 25 1226
14 10 9 1232
21 19 18 1237
18 20 20 1243
21 26 33 1248
34 45 63 1254
33 47 69 1259
19 34 56 1265
14 29 49 1270
14 30 51 1276
27 49 61 1281
21 40 43 1287
12 25 25 1292
13 27 21 1298
22 37 27 1303
36 50 34 1308
28 42 28 1314
23 36 23 1319
27 41 29 1324
31 43 35 1329
29 38 34 1335
33 39 38 1340
35 39 42 1345
34 38 42 1350
36 38 42 1355
44 47 49 1360
49 54 46 1365
49 56 42 1370
43 50 35 1375
41 44 27 1380
53 54 40 1384
64 61 53 1389
74 67 70 1394
68 63 75 1399
75 69 69 1404
81 79 66 1408
82 85 64 1413
76 78 54 1418
76 78 57 1423
84 83 65 1428
94 91 67 1433
97 90 65 1437
101 92 64 1442
111 103 69 1447
119 110 76 1452
112 107 75 1457
115 114 79 1463
119 119 84 1468
124 124 91 1473
131 127 99 1479
146 138 109 1484
160 150 119 1490
185 174 138 1496
192 185 143 1501
197 191 143 1507
202 195 141 1514
210 203 137 1520
228 220 140 1526
235 226 133 1533
238 231 124 1540
267 258 138 1547
283 278 145 1554
289 288 152 1562
306 309 170 1569
313 321 179 1577
328 337 190 1585
352 363 205 1593
385 393 217 1602
409 413 233 1611
443 450 252 1620
471 482 270 1629
504 520 291 1638
525 544 295 1648
552 572 310 1658
600 620 332 1668
657 682 369 1679
697 724 377 1690
726 758 377 1701
765 801 378 1712
807 845 380 1724
854 893 395 1736
904 941 413 1748
955 992 456 1760
994 1040 493 1772
1044 1099 534 1785
1093 1163 587 1798
1117 1198 612 1811
1149 1230 634 1825
1208 1291 686 1838
1274 1353 743 1852
1320 1397 794 1866
1340 1417 824 1880
1379 1460 867 1894
1439 1522 929 1908
1481 1563 932 1922
1531 1618 949 1937
1600 1691 986 1951
1678 1782 1044 1965
1776 1876 1120 1979
1843 1963 1201 1993
1884 2017 1258 2007
1911 2073 1277 2021
1953 2127 1344 2035
2022 2205 1437 2048
2062 2250 1488 2061
2092 2284 1528 2074
2147 2318 1562 2086
2183 2363 1618 2098
2213 2400 1643 2109
2253 2437 1662 2120
2291 2470 1696 2130
2315 2499 1731 2140
2332 2525 1755 2149
2345 2546 1777 2156
2352 2559 1806 2163
2365 2563 1826 2169
2367 2556 1807 2174
2363 2549 1789 2210
2366 2552 1790 2199
2365 2552 1786 2188
2350 2537 1754 2177
2338 2522 1723 2165
2332 2513 1726 2153
2306 2495 1720 2141
2280 2476 1713 2129
2273 2460 1704 2116
2253 2431 1667 2104
2219 2396 1618 2091
2186 2361 1560 2077
2159 2330 1510 2064
2128 2289 1462 2050
2077 2230 1395 2037
2024 2171 1349 2022
1946 2115 1322 2008
1893 2053 1271 1994
1835 1986 1211 1979
1777 1902 1188 1964
1712 1833 1141 1949
1625 1757 1073 1934
1558 1684 1010 1919
1485 1600 943 1904
1416 1516 877 1888
1341 1421 817 1872
1274 1337 763 1856
1214 1254 702 1840
1133 1165 626 1824
1049 1072 541 1808
965 984 474 1791
894 912 425 1775
823 836 385 1758
741 749 334 1741
652 652 288 1724
582 580 267 1707
510 508 250 1690
442 441 237 1673
376 371 221 1656
323 317 193 1639
290 280 170 1621
246 230 126 1604
200 186 92 1586
181 168 79 1569
137 128 58 1551
109 105 54 1533
98 94 57 1515
75 71 52 1498
68 62 56 1480
62 54 55 1462
46 43 49 1444
37 33 41 1426
34 31 41 1408
12 10 13 1390
30 29 35 1372
15 16 19 1354
8 5 8 1336
20 13 25 1318
23 14 40 1301
19 10 38 1283
20 15 55 1265
7 5 24 1247
2 2 6 1229
4 3 10 1211
15 14 24 1194
13 14 27 1176
8 10 22 1158
3 5 17 1141
6 7 26 1123
17 13 42 1106
10 9 34 1088
14 13 34 1071
13 15 27 1054
7 9 19 1036
2 3 13 1019
2 4 19 1002
4 5 29 986
7 7 37 969
9 8 47 952
6 5 31 936
9 6 27 919
10 5 23 903
18 11 28 887
12 6 26 871
7 5 30 855
7 8 39 839
5 4 37 824
5 4 36 808
3 1 22 793
4 1 19 778
13 9 37 763
10 7 39 748
0 1 21 734
1 1 23 719
5 6 41 705
9 7 37 691
9 8 27 677
15 15 31 664
11 15 21 650
0 1 3 637
4 7 6 624
7 9 10 611
4 5 9 599
10 13 31 587
17 21 60 575
9 14 53 563
2 5 39 551
4 6 45 540
6 9 58 529
8 9 52 518
13 12 54 508
11 10 38 498
4 4 18 488
7 7 20 478
2 3 12 469
5 11 27 460
9 17 35 451
1 3 11 442
0 2 7 434
3 5 13 426
7 12 22 419
3 9 16 412
4 10 19 405
1 4 14 398
0 2 15 392
0 1 15 386
5 7 39 380
5 5 35 375
3 3 18 370
1 1 14 366
9 7 35 362
11 9 31 358

3
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by b4codes
0

Assuming the correlation is of a linear type, then you could use a method known as linear regression/method of least squares, to map an equation of the form y=mx + c for each dataset.

That is to say have a linear equation for the red, blue and green data points.

Once equations have been derived for each dataset you can intelligently obtain some sort of pattern (correlation) between them.

If the data is not of a linear type, then things become more complex, although the method of least squares can still be applied. For instance, suppose that the equation is quadratic, meaning that f(x) = ax^2 + bx + c, where a, b and c are not yet known. We now seek the values of a, b and c that minimize the sum of the squares of the residuals:

[tex]S=\sum_{i=1}^n(y_i-f(x_i))^2[/tex]

Simple as pie.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.