Calculate the required area

1 Ansicht (letzte 30 Tage)
Nikodin Sedlarevic
Nikodin Sedlarevic am 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
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 Kommentar
Riccardo Scorretti
Riccardo Scorretti am 30 Apr. 2022
In this way you are computing volumes, not surfaces. The problem is with mathematics, not with MATLAB.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Riccardo Scorretti
Riccardo Scorretti am 30 Apr. 2022
Bearbeitet: Riccardo Scorretti am 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)
wall1 = 1.8102
wall3 = integral(@(x) g(x,d), a, b)
wall3 = 0.8387
and
wall2 = integral(@(y) g(a,y), c, d)
wall2 = 1.7679
wall4 = integral(@(y) g(b,y), c, d)
wall4 = 0.7802
The case of the roof is quite different: it is a 2D integral of the surface given defined by the map , that is:
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)
roof = 18.5637
The bottom line is:
tot = wall1 + wall2 + wall3 + wall4 + roof
tot = 23.7605

Weitere Antworten (0)

Kategorien

Mehr zu Smoothing 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!

Translated by