How to remove confidence bounds in LinearModel.fit Tool box?
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Ayush
on 3 Jan 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
0 Comments
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!