Shade area under curve between two x values
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
pvtstaticvoid
am 16 Jan. 2019
Beantwortet: Robert U
am 16 Jan. 2019
If I have a function, how do I shade the area underneath its graph between two x values? I've been using the area function, but it only lets me shade the area underneath the entire curve, which is not what I want.
For example, between to ?
0 Kommentare
Akzeptierte Antwort
Robert U
am 16 Jan. 2019
Hi pvtstaticvoid:
You may define different intervals with area()-function. Using hold you can plot into the same axes as the function is plotted:
% define example function
f = @(x) x.^3;
% define plot intervals
plotInterval = -8:0.1:8;
areaInterval = 4:0.1:6;
% plot into one figure/axes
fh = figure;
ah = axes(fh);
plot(ah,plotInterval,f(plotInterval))
hold on
area(ah,areaInterval,f(areaInterval))
Kind regards,
Robert
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Two y-axis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!