Adding multiple linear fit equations into a subplot
Mostrar comentarios más antiguos
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

Respuestas (1)
Ameer Hamza
el 12 de Abr. de 2020
0 votos
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.
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!