Plotting error bars on curve
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)’)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)’) 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)’) error bars, curve plotting, resample data, plot MATLAB Answers — New Questions