Adding multiple linear fit equations into a subplot

Hello,
I am trying to display multiple linear fit equations into the subplot but the "Tools -> Basic Fitting" option is only allowing for one of the equations to be displayed. Is there anything else I can do? Here is the code and picture of the subplot
i = 1;
while i <= length(t_room)
theta_forced(i) = log((t_forcedfan(i) - t_room(i))/( t_forcedfan(1) - t_room(i)));
theta_natins(i) = log((t_naturalins(i) - t_room(i))/(t_naturalins(1) - t_room(i)));
theta_natunins(i) = log((t_naturalunins(i) - t_room(i))/(t_naturalunins(1) - t_room(i)));
i = i + 1;
end
figure
subplot(2,2,1)
b1 = plot(time(1:11000),theta_forced(1:11000));
bL1 = "Forced";
title('Forced')
xlabel('Time (s)')
ylabel('ln(\theta)')
legend([b1],[bL1])
hold on
subplot(2,2,2)
b2 = plot(time(1:11000),theta_natins(1:11000));
bL2 = "Natural Insulated";
title('Natural Insulated')
xlabel('Time (s)')
ylabel('ln(\theta)')
legend([b2],[bL2])
hold on
subplot(2,2,3)
b3 = plot(time(1:11000),theta_natunins(1:11000));
bL3 = "Natural Uninsulated";
title('Natural Uninsulated')
xlabel('Time (s)')
ylabel('ln(\theta)')
legend([b3],[bL3])
sgtitle('Dimensionless Temperature vs Time')
hold off

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 4월 12일

0 개 추천

The basic fitting tool provided in Tools -> Basic Fitting does not give a lot of options. If you want to have better control over the fitted curves, then see the fit() function: https://www.mathworks.com/help/curvefit/fit.html.
You can also try lsqlin(): https://www.mathworks.com/help/releases/R2020a/optim/ug/lsqlin.html for linear curve fitting. Similarly, lsqcurvefit: https://www.mathworks.com/help/releases/R2020a/optim/ug/lsqcurvefit.html is also a good option.

카테고리

도움말 센터File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2020년 4월 12일

답변:

2020년 4월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by