Plotting Uncertainty (Bounded Line)
Versione 1.0.4 (3,47 KB) da
Darin Koblick
Display the upper and lower uncertainty bounds about X and Y datasets in a highly customizable style
Description
Plot the 2-D uncertainty bounds (upper and lower) about a standard 2-D line plot of x and y data. The bounds are assumed to be +/- of the specified uncertainty value about the y data. This routine features a variable number of user input properties allowing the user to specify customized settings for both the built-in plot and patch routines.
Syntax
plotUnc(x,y,u,l)
plotUnc(x,y,u,l,ColorSpec)
plotUnc(y,u,l)
plotUnc(y,u,l,ColorSpec)
plotUnc(__,Name,Value)
plotUnc(ax, __)
h = plotUnc(__)
Examples
Create an Uncertainty Plot
Create x as a vector of linearly spaced values between 0 and 2π. Use an increment of π/100 between the values. Create y values equal to the sine of x and display a bounded region of ±0.5 about y as defined by the upper and lower bounds (ub and lb).
x = 0:pi/100:2*pi;
y = sin(x);
ub = ones(size(x))./2;
lb = ones(size(x))./2;
plotUnc(x,y,ub,lb);
Plot Uncertainty Without Shading
In some instances, it may be desirable to display bounds about a 2-D dataset without shading. Using the previous example, this can be customized by adding input arguments for the patch routine
plotUnc(x,y,ub,lb,'FaceColor','none');
Plot Multiple Uncertainties
Create x as a vector of 100 linearly spaced values between -2π and 2π. The underlying y data sets are defined as sine and cosine values of x. Plot the uncertainties about both data sets and set their transparency.
x = linspace(-2*pi,2*pi,100)';
y1 = sin(x);
y2 = cos(x);
ub = ones(size(y1))./2;
lb = ones(size(y1))./2;
plotUnc([x,x],[y1,y2],[ub,ub],[lb,lb],'EdgeColor','none','FaceAlpha',0.2);
legend('sin(x)','cos(x)');
Cita come
Darin Koblick (2024). Plotting Uncertainty (Bounded Line) (https://www.mathworks.com/matlabcentral/fileexchange/116385-plotting-uncertainty-bounded-line), MATLAB Central File Exchange. Recuperato .
Compatibilità della release di MATLAB
Creato con
R2021a
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS LinuxTag
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Scopri Live Editor
Crea script con codice, output e testo formattato in un unico documento eseguibile.