Clear Filters
Clear Filters

how can I find the surface area and the volume through this code?

2 views (last 30 days)
v =[2;0;1;9;0;1;3;0;1];
m = max(v);
n = mean(v);
syms x;
f= @(x)(3+sin(m*x)+cos(n*x));
ezplot(f,[-pi,pi]);
dfx(x)= diff(f(x)); dfx(x)
A=2*pi*int(f*sqrt(1+dfx^2),-2*pi,2*pi);
An = double(A);
V=pi*int((3+sin(n*x))^2,-2*pi,2*pi);
Vn=double(V);

Answers (2)

Carlos Guerrero García
Carlos Guerrero García on 22 Nov 2022
The surface which area (and volume) is found, can be visualized using the following code:
v =[2;0;1;9;0;1;3;0;1]; % Line in the question
m = max(v); % Line in the question
n = mean(v); % Line in the question
[x,t]=meshgrid(-2*pi:pi/72:2*pi,0:pi/72:2*pi); % Adding the 't' variable for the rotation
y=3+sin(m*x)+cos(n*x); % The function (in the question) to be rotated
surf(x,y.*cos(t),y.*sin(t)) % The surface generated in the rotation

Torsten
Torsten on 14 Nov 2022
v =[2;0;1;9;0;1;3;0;1];
m = max(v);
n = mean(v);
f = @(x)(3+sin(m*x)+cos(n*x));
x = -2*pi:0.01:2*pi;
plot(x,f(x))
df = @(x)m*cos(m*x)-n*sin(n*x);
A = 2*pi*integral(@(x)f(x).*sqrt(1+df(x).^2),-2*pi,2*pi)
A = 1.3816e+03
V = pi*integral(@(x)f(x).^2,-2*pi,2*pi)
V = 381.1362

Categories

Find more on Interpolation 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!