Plotting error bars on curve
4 次查看(过去 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!