There is anyway that I can plot a graph like this in MatLab with standard deviation ?
1 次查看(过去 30 天)
显示 更早的评论
2 个评论
MarKf
2023-9-6
Likely yes.
Not sure tho what you mean with "stadard deviation". As in, you can easily calculate it with stdev = std(data) and you can visualize it in the graph with text (btw, also not sure what Y = 10,657 x 10,222 means), but do you mean SError? do you want the std of the data visualized (like errorbars on the points)? do you want to use std as a variable (like y, and then do a regression on that)? or you want to have the residuals plotted? or do you want the confidence bounds of the regression?
You can do all that and more.
回答(2 个)
Image Analyst
2023-9-6
Do you mean like the "errorbar" LinePlot shown about half way down the page here:
0 个评论
MarKf
2023-9-6
编辑:MarKf
2023-9-12
n = 15; x = randn(n,1); y = randn(n,1);
sx = std(x); sy = std(y); %maybe non-randn data will have smaller std
lregsrts = regstats(y,x,'linear'); %edit: y first in this function
betal = lregsrts.beta; [X, ixd] = sort(x); %fitlm would be faster, but you can find that example everywhere
Y = ones(size(X))*betal(1) + betal(2)*X;
scatter(x,y,50,'kd','filled'); %diamonds (romboids, kites) as in OP figure
hold on
plot(X,Y,'k','LineWidth',3);
errorbar(x,y,sx,'k','horizontal')
errorbar(x,y,sy,'k')
annotation('textbox',[.15 .2 .1 .1] ,'string',...
['R^2 = ' num2str(lregsrts.rsquare) newline 's_x = ' num2str(sx)...
newline 's_y = ' num2str(sy)],'LineStyle','none') %also text
box on, grid on, set(gca, 'YGrid', 'on', 'XGrid', 'off'), hold off% as in OP figure
Edit: This is what was asked but I feel that this is not what they wanted anyway, it's redundant and uncommon. Typical errorbars on a line of data e.g. obtained by averagin (but then not a regression, unless it's not std) it'd be more likely.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Errorbars 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!