plotting this volume, in matlab by rotating it

조회 수: 1 (최근 30일)
Nitin Kumar
Nitin Kumar 2022년 1월 7일
답변: Rahul 2024년 9월 20일
how do i plot this this is my code but this does not works i suspect this is wrong
for the 2ns part
1 R1 around OC
clc
clear all
syms x
y = sqrt(sqrt(x))
ll = 0
ul = 1
vol = int(pi*y^2,0,1)
clear all
x = linspace(0,1);
y1 = sqrt(x);
y2 = 0.*x;
X1 = [x,fliplr(x)];
Y1 = [y1,flip(y2)];
fill(X1,Y1,'r')
[U, V, W] = cylinder(y1-y2)
rotate(surf(U,V,W,'EdgeColor','none'),[1 0 0],90)

답변 (1개)

Rahul
Rahul 2024년 9월 20일
In order to obtain the plot shared in the question you can follow the following example:
% Define the range for x, can be adjusted
x = linspace(0, 1, 100);
% For R1, we have to get the Area Under Curve (AUC) of x = y
y = x;
x_fill = [x, fliplr(x)]; % Obtaining arrays to define AUC
y_fill = [y, zeros(size(y))];
x1 = sqrt(sqrt(y_fill)); % AUC for the curve y = x^(1/4)
% Using 'fill' function to plot the AUC
p1 = fill(x_fill, y_fill, 'cyan', 'FaceAlpha', 0.7, 'EdgeColor', 'none');
hold on
p2 = fill(y_fill, x_fill, 'green', 'FaceAlpha', 0.8, 'EdgeColor', 'none');
hold on
p3 = fill(y_fill, x1, [1, 0.5, 0], 'FaceAlpha', 0.9, 'EdgeColor', 'none');
xlabel('x');
ylabel('y');
grid on;
axis equal;
legend([p3, p1, p2], {'R3: y = x^{1/4}', 'R1', 'R2'}, 'Location', 'best');
hold off;
This will give you the desired plot which would look like:
You can refer to the following Mathworks documentation to know more about the 'fill' function:
Hope this resolves your query. Thanks.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by