필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
Ranjith Madhana Gopal
Ranjith Madhana Gopal 2022년 4월 20일
답변: Ayush 2024년 1월 3일
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');

답변 (1개)

Ayush
Ayush 2024년 1월 3일
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

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by