How to fill in the area under the curve
5 views (last 30 days)
Show older comments
I'm trying to fill in the area under the curve from 0-0.21 in one color and 0.21-0.45 in another color.
clc
clear all;
x=[0.00
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
0.09
0.10
0.11
0.12
0.13
0.14
0.15
0.16
0.17
0.18
0.19
0.20
0.21
0.22
0.23
0.24
0.25
0.26
0.27
0.28
0.29
0.3
0.31
0.32
0.33
0.34
0.35
0.36
0.37
0.38
0.39
0.4
0.41
0.42
0.43
0.44
0.45
0.46
0.47
];
r=[322.7337814 % this is 1/r
326.4298381
330.3538959
334.5184218
338.9371002
343.6249656
348.598554
353.8760759
359.4776157
365.4253608
371.7438663
378.4603625
385.6051117
393.2118255
401.3181536
409.9662594
419.2035004
429.0832367
439.6657964
451.0196342
463.2227305
476.3642911
490.5468243
505.8886991
522.5273178
540.6230829
560.364401
581.9740526
605.7173855
631.9129697
660.9466231
693.2901197
729.5265142
770.3849808
816.7896168
869.9292081
931.3592715
1003.155249
1088.149497
1190.310914
1315.378513
1471.972025
1673.658647
1943.097228
2321.186314
2890.040873
3842.399615
5762.514434
];
figure;
hold on;
plot(x,r,'r')
xlabel('x (conversion fraction)')
ylabel('1/r (kgcat*hr/kgmolEB)')
grid on;
hold off;
W=trapz(x,r);
FA0=613.212;
porosity=0.45;
rho_bulk=2145.27*(1-porosity);
V=FA0*0.454*W/rho_bulk
0 Comments
Accepted Answer
Star Strider
on 3 Jul 2025
Perhaps something like this --
clc
clear all;
x=[0.00
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
0.09
0.10
0.11
0.12
0.13
0.14
0.15
0.16
0.17
0.18
0.19
0.20
0.21
0.22
0.23
0.24
0.25
0.26
0.27
0.28
0.29
0.3
0.31
0.32
0.33
0.34
0.35
0.36
0.37
0.38
0.39
0.4
0.41
0.42
0.43
0.44
0.45
0.46
0.47
];
r=[322.7337814 % this is 1/r
326.4298381
330.3538959
334.5184218
338.9371002
343.6249656
348.598554
353.8760759
359.4776157
365.4253608
371.7438663
378.4603625
385.6051117
393.2118255
401.3181536
409.9662594
419.2035004
429.0832367
439.6657964
451.0196342
463.2227305
476.3642911
490.5468243
505.8886991
522.5273178
540.6230829
560.364401
581.9740526
605.7173855
631.9129697
660.9466231
693.2901197
729.5265142
770.3849808
816.7896168
869.9292081
931.3592715
1003.155249
1088.149497
1190.310914
1315.378513
1471.972025
1673.658647
1943.097228
2321.186314
2890.040873
3842.399615
5762.514434
];
Lv1 = x <= 0.21;
Lv2 = x >= 0.21;
figure;
hold on;
plot(x,r,'r')
patch([x(Lv1); flip(x(Lv1))], [zeros(size(x(Lv1))); flip(r(Lv1))], 'g', FaceAlpha=0.5, EdgeColor='none')
patch([x(Lv2); flip(x(Lv2))], [zeros(size(x(Lv2))); flip(r(Lv2))], 'r', FaceAlpha=0.5, EdgeColor='none')
xlabel('x (conversion fraction)')
ylabel('1/r (kgcat*hr/kgmolEB)')
grid on;
hold off;
W=trapz(x,r);
FA0=613.212;
porosity=0.45;
rho_bulk=2145.27*(1-porosity);
V=FA0*0.454*W/rho_bulk
.
2 Comments
More Answers (0)
See Also
Categories
Find more on Red in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!