Problem/question with regression

2 ビュー (過去 30 日間)
Teshan Rezel
Teshan Rezel 2021 年 5 月 31 日
回答済み: William Rose 2021 年 5 月 31 日
Hi folks,
I have the following data:
Reflectance R G B
7.51 109 54 124
3.17 57 30 63
1.24 30 17 31
I am trying to get a relationship for reflectance based on the R, G and B values. Doing this using simultaneous equations yields the following coefficients:
0.452923977
-0.538011696
-0.103274854
which is problematic because it gives me negative values for fomr RGB values, which is incorrect. So I tried to regress the table above in Matlab's curve fitting app, but it doesn't let me as the matrix dimensions aren't compatible.
Is there a way to get around this problem and regress the data?
Thanks

採用された回答

William Rose
William Rose 2021 年 5 月 31 日
You need at least one more data point to do a standard regression, so that you have more equations than unknowns.
Even with more points, it is possible that the regression equation will predict negative reflectance for some combinatons of R, G, B. If you want a model that will never give values outside [0,1], then you need a nonlinear model. You could take the linear prediction and apply a hard or smooth limit funciton to it. Suppose your linear model is rinit=a*R+b*G+c*B. The code below shows final reflectance, rfinal, computed with hard and smooth limits.
rinit=-1:.05:2;
rfinalH=min(max(rinit,0),1);
rfinalS=exp(4*(rinit-.5))./(1+exp(4*(rinit-.5)));
plot(rinit,rfinalH,'rx-',rinit,rfinalS,'bo-');
xlabel('Linear Reflectance Prediction'); grid on;
ylabel('Final Reflectance'); legend('Hard','Soft');
Try it.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by