Plotting Uncertainty (Bounded Line)
Version 1.0.4 (3,47 KB) von
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)');
Zitieren als
Darin Koblick (2024). Plotting Uncertainty (Bounded Line) (https://www.mathworks.com/matlabcentral/fileexchange/116385-plotting-uncertainty-bounded-line), MATLAB Central File Exchange. Abgerufen.
Kompatibilität der MATLAB-Version
Erstellt mit
R2021a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Live Editor erkunden
Erstellen Sie Skripte mit Code, Ausgabe und formatiertem Text in einem einzigen ausführbaren Dokument.
Version | Veröffentlicht | Versionshinweise | |
---|---|---|---|
1.0.4 | added more content |
||
1.0.3 | added additional content |
||
1.0.2 | Adjusted pictures in description |
||
1.0.1 | Added more content in the description |
||
1.0.0 |