fitlm and exponential model help
4 次查看(过去 30 天)
显示 更早的评论
Hi
I have a set of data, which is voltage from a sensor aganist temperture.
As temperture increase the voltage output from the sensor will drop, even though the sensing enviroment in the same.
Therefore i need to be able to calulate the correction factor so the output is very close to when sensor is expose to 20 degrees.
I am using fitlm, but when i use exponential i am getting errors, which is not then when i use Quadratic
This is what i am using
no2Model = fitlm(iot_temperature, voltage_differnce_no2, "exponential");
Is this the correct command to use?
采纳的回答
Star Strider
2022-10-5
Example —
t = linspace(0, 10, 25);
y = 3*exp(-0.25*t) + 0.5*randn(size(t)) + 1;
fcn = @(b,x) b(1).*exp(b(2).*x) + b(3);
B0 = randn(3,1);
mdl = fitnlm(t,y,fcn,B0)
[yfit,yci] = predict(mdl,t(:));
figure
hp{1} = plot(t, y, '.', 'DisplayName','Data');
hold on
hp{2} = plot(t, yfit, '-r', 'DisplayName','Model Fit');
hp{3} = plot(t, yci, ':r', 'DisplayName','±95% CI');
hold off
grid
xlabel('t')
ylabel('y')
legend([hp{1},hp{2},hp{3}(1)], 'Location','best')
.
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!