Area under the curve with conditions?

3 ビュー (過去 30 日間)
MUKESH KUMAR
MUKESH KUMAR 2019 年 8 月 8 日
コメント済み: Star Strider 2021 年 1 月 5 日
I want to do following tasks,
First generate a time series load data between 550-1000 for one day 30 min interval, so is load(48*1) dataset
then set level_1 = 750 and draw a line on the graph,
then find out the area above this level_1 line and area under seprate level (lets say level_2 = 600) line seprately

採用された回答

Star Strider
Star Strider 2019 年 8 月 8 日
Try this:
t = 1:48; % Time Vector
load = randi(1000, 1, 48); % Create Data
level_1 = 750;
level_2 = 600;
above_level_1 = load >= level_1; % Logical Index Vector
area_1 = trapz(t(above_level_1), load(above_level_1)); % Area Under ‘Level_1’
below_level_2 = load <= level_2; % Logical Index Vector
area_2 = trapz(t(below_level_2), load(below_level_2)); % Area Under ‘Level_2’
figure
plot(t, load)
hold on
plot(xlim, [1 1]*level_1)
plot(xlim, [1 1]*level_2)
hold off
grid
  10 件のコメント
MUKESH KUMAR
MUKESH KUMAR 2021 年 1 月 5 日
Can i get the area with these conditons at each continous interval.
The problem is that when above_level_1 having only one continuous data(1) then it can not calculate area but it should calculate for that interval at that point.??
Star Strider
Star Strider 2021 年 1 月 5 日
I do not understand what you are asking.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by