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!