Calculate the required area
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Nikodin Sedlarevic
il 30 Apr 2022
Modificato: Riccardo Scorretti
il 30 Apr 2022
I would like to paint a building (all 5 surfaces) that has 4 vertical straight walls, the upper surface (roof) is described by the function z = g (x, y) for (x, y) ∈ [0.0,4.40] × [0.0, 4.20]. The lower edge of the building is at a height of z (x, y) ≡0. Calculate the required area.
This is the area I would like to calculate
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/983685/image.png)
I tried to calculate like this but it does not get me the right answer. Any help?
g = @(x, y) 1./((2+1.1.*x.^2+1.1.*y.^2).^(1/2));
a=0.0;
b=4.40;
c=0.0;
d=4.20;
s1= 1./((2+1.1.*(0.0).^2+1.1.*(0.0).^2).^(1/2));
s2= 1./((2+1.1.*(4.40).^2+1.1.*(4.20).^2).^(1/2));
s3= 1./((2+1.1.*(0.0).^2+1.1.*(4.20).^2).^(1/2));
s4= 1./((2+1.1.*(4.40).^2+1.1.*(0.0).^2).^(1/2));
roof = integral2(g,a,b,c,d);
wall1 = integral2(g,a,b,0,s1);
wall2 = integral2(g,a,b,0,s2);
wall3 = integral2(g,c,d,0,s3);
wall4 = integral2(g,c,d,0,s4);
area = roof + wall1 + wall2 + wall3 + wall4;
1 Commento
Riccardo Scorretti
il 30 Apr 2022
In this way you are computing volumes, not surfaces. The problem is with mathematics, not with MATLAB.
Risposta accettata
Riccardo Scorretti
il 30 Apr 2022
Modificato: Riccardo Scorretti
il 30 Apr 2022
Let's start by checking the function g = profile of your building:
g = @(x, y) 1./((2+1.1.*x.^2+1.1.*y.^2).^(1/2));
a=0.0;
b=4.40;
c=0.0;
d=4.20;
[x, y] = meshgrid(a:0.4:b, c:0.4:d);
figure ; mesh(x, y, g(x,y)) ; axis image ; grid on ;
axis([a, b, c, d, 0 inf]);
camproj perspective ; box on
xlabel('x') ; ylabel('y');
For the 4 walls, the computation boils up into a simple 1D integral:
wall1 = integral(@(x) g(x,c), a, b)
wall3 = integral(@(x) g(x,d), a, b)
and
wall2 = integral(@(y) g(a,y), c, d)
wall4 = integral(@(y) g(b,y), c, d)
The case of the roof is quite different: it is a 2D integral of the surface given defined by the map
, that is:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/983705/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/983710/image.png)
Assuming that g is given as a numerical function (and not analytically), the derivatives must be computed numerically as well, for instance by finite difference. This will introduce some numerical error, which will be quite negligible if the surface is smooth enough:
dx = 1.0E-5 ; dy = dx;
gx = @(x,y) (g(x+dx,y) - g(x-dx,y))/(2*dx);
gy = @(x,y) (g(x,y+dy) - g(x,y-dy))/(2*dy);
roof = integral2(@(x,y) sqrt(1 + gx(x,y).^2 + gy(x,y).^2), a, b, c, d)
The bottom line is:
tot = wall1 + wall2 + wall3 + wall4 + roof
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Smoothing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!