Borrar filtros
Borrar filtros

How to remove confidence bounds in LinearModel.fit Tool box?

3 visualizaciones (últimos 30 días)
Ranjith Madhana Gopal
Ranjith Madhana Gopal el 20 de Abr. de 2022
Respondida: Ayush el 3 de En. de 2024
figure(14)
myfit = LinearModel.fit(thetha_3_y_deg,thetha_4_y_deg);
%set(myfit.coefCI,'Visible','off');
plot(myfit.coefCI,'Visible','off');
hold on;
plot(myfit,'marker','o','MarkerFaceColor','b');

Respuestas (1)

Ayush
Ayush el 3 de En. de 2024
Hi Ranjith,
I understand that you want to remove the confidence bound while plotting the linear fit.
To do so, you can make use of the “visible” property of the plot. Refer the below example code for better understanding:
% Generate some synthetic data for the example
thetha_3_y_deg = (1:100)'; % Independent variable (e.g., theta 3 in degrees)
thetha_4_y_deg = 2.5 * thetha_3_y_deg + randn(100, 1) * 10; % Dependent variable (e.g., theta 4 in degrees) with some noise
% Fit the linear model using fitlm (since LinearModel.fit is deprecated)
myfit = LinearModel.fit(thetha_3_y_deg, thetha_4_y_deg);
% Open a new figure
figure(14);
% Plot the original data points
plot(thetha_3_y_deg, thetha_4_y_deg, 'x', 'MarkerFaceColor', 'b');
hold on; % Keep the plot for further additions
% Plot the fitted line without confidence bounds
p = plot(myfit);
p(end-1,1).Visible='off'; % This will help in visualizing fit without the confidence bound
p(end,1).Visible='off'; % This will help in visualizing fit without the confidence bound
% Customize the plot
xlabel('Theta 3 (degrees)');
ylabel('Theta 4 (degrees)');
title('Linear Fit without Confidence Bounds');
hold off; % No more additions to the plot
For more information on fit Linear Regression, you can refer to the documentation page given below:
Regards,
Ayush

Categorías

Más información sobre Linear Algebra en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by