plotting this volume, in matlab by rotating it
2 次查看(过去 30 天)
显示 更早的评论
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)
0 个评论
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!