Plotting error bars on curve
조회 수: 5 (최근 30일)
이전 댓글 표시
Hello,
I have code that compares two devices and I am plotting the error on y-axis throughout a gait cycle % (on the x axis).
I am trying to get the error bars to plot the standard error but I am having an unexpected result when plotting the curve.
This is the code I am working with.
Initially x, ave_diff and SE are 1X1000 and I would like to plot it over a gait cycle from 0-100% hence why I have resampled the signals.
However, when I run this code I have extra values at the end of the plot, yet the resmapled variables are all 101X1?
I cannot spot my error and was wondering if someone my point me in the correct direction or suggest where my fault lies.
I have attached the curve and the area where the issue lies, you can see the standard error bars also become strange.
Thanks in advance
figure()
x = smooth(resample((gc),101,length(gc),'Dimension',1));
ave_diff_resample = smooth(resample((ave_diff),101,length(ave_diff),'Dimension',1));
SE_resampled = smooth(resample((SE),101,length(SE),'Dimension',1));
set(gcf,'Color','w');
%standard error plot
plot(x, ave_diff_resample,'-','Color',[0 0 0],'linewidth',0.5)
hold on
% Adding error bars
errorbar(x, ave_diff_resample, SE_resampled, 'vertical');
hold on
hline = refline(0, 0);
hline.Color = 'k';
xlim([0 100]);
ylim([-15 15]);
legend('Signed Difference', 'Standard error bar')
xlabel('Gait cycle %')
ylabel('Difference (deg)')
댓글 수: 0
채택된 답변
Star Strider
2024년 6월 20일
I really can’t do anything without the data. The rest of the code (that imports the data and processes it including calculating the standard errors) would be helpful as well. (An image may be worth a thousand words, however the data files and code are worth a thousand images on MATLAB Answers.)
pngs = dir('*.png');
for k = 1:numel(pngs)
figure
imshow(imread(pngs(k).name))
end
.
댓글 수: 11
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!