Error bars at intervals of data
조회 수: 51(최근 30일)
I have been trying to plot the error bars on a curve, however I have ~120,000 data points in each file so error bars on all curves gets too crowded on the graph. I was wondering if anyone could please help me out about how I would go about plotting the error bars at intervals of every 10,000 data points or so?
Here is my code so far:
% Loading the xlsx file
FILEPATH='/Volumes/Lexar/Final Project/Edited Folders/Compression Data/';
num1 = xlsread(strcat(FILEPATH,'Compress D50 1.xlsx'),1,'A:O');
% In num1 you only have those two columns, so for Load related data
% you need to use only the 2nd column (K)
Load1 = num1(:,11);
% For displacement you use the first column (J)
Displacement1m = num1(:,10);
A = 0.0004;
L = 0.02;
% Plot the curves in one figure %
% Velocity 1 mm/s %
% Ensure to change the title depending on the density %
title('Static Compression - Stress vs. Strain for Density 50 Silicon','FontSize',14);
errStress = num1(:,13);
errStrain = num1(:,14);
eStress = std(Stress1)*ones(size(errStress));
eStrain = std(Strain1)*ones(size(errStrain));
Many thanks for the help - it is really appreciated.
Shivam Chaturvedi 2016년 3월 3일
It doesn't look like there's a direct way to restrict the individual error bars from being created.
However, you can remove the error values from the other points i.e. make them zero so it doesn't come up as an error bar. It still might not look good, but you can give it a try.
I tried the following example to try this out and print every 3rd error bar on an example shown here:
% error bar demo
x = 0:pi/10:pi;
y = sin(x);
e = std(y)*ones(size(x)); % calculate the initial errors
% copy the initial errors and make the ones not required as zero
valToKeep = 1:3:length(z); % keep every third bar, start from 1
z = e;
if ~any(valToKeep == i)
z(i) = 0;
errorbar(x,y,z) % instead of errorbar(x, y, e) keep all third bars
You can then try to tinker with the error bar properties to adjust more visual cues as necessary.
Hope this helps!