How to remove confidence bounds in LinearModel.fit Tool box?
4 次查看(过去 30 天)
显示 更早的评论
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');
0 个评论
回答(1 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!