필터 지우기
필터 지우기

Stretch a plot while keeping area under same

조회 수: 9 (최근 30일)
Sanchit Sharma
Sanchit Sharma 2021년 8월 25일
답변: DGM 2021년 8월 25일
I have a plot with x and y axis data. How can I strech it whilst keeping area under it same? Can you please provide an example.
Thanks!

답변 (1개)

DGM
DGM 2021년 8월 25일
If you scale the curve in the X direction by a factor of 2, then scale the curve in Y by a factor of 1/2.
X = 0:100; % linear x
Y = rand(1,101); % random y
plot(X,Y)
A1x = trapz(X,Y) % area under the curve
A1x = 46.8929
A2x = trapz(2*X,Y) % area under the curve when X is stretched by 2
A2x = 93.7858
A2xc = trapz(2*X,Y/2) % corrected
A2xc = 46.8929
Ignoring trying to intuit the calculus, it's easier to look at this in relative terms. Consider the curve occupying a rectangular box, wherein the area under the curve (Ac) occupies some fraction of the total area (At) of the box. If you scale one dimension of the box (and everything therein) by 2, the total area is doubled, but the area ratio remains constant. In other words, Ac is simply proportional to At.
If there's something other than a simple scale transformation going on (e.g. changing data extents), that may not hold true.

카테고리

Help CenterFile Exchange에서 Exploration and Visualization에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by