フィルターのクリア

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 Center および File ExchangeLinear Algebra についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by