# Unintended plot while using the cylinder function

1 ビュー (過去 30 日間)
Kevin Hanekom 2021 年 10 月 17 日
コメント済み: Kevin Hanekom 2021 年 10 月 18 日
Hello!
I have been attempting to create a 3d object by rotating a 2d plot utilizing the cylinder function. But for some reason my plot comes out with this funnel attached to the bottom. Could you possibly bring some insight on how I may be able to create the shape located above the funnel? To be clear the shape above is exactly what we would expect.
Heres the code.
Yieldstr = 1000; % KPa, Sets the str for all following 2d Plots
minValue = -4*Yieldstr;
maxValue = 4*Yieldstr;
fidelity = Yieldstr/125; %able to use much higher fidelity in 2d
sigx = minValue:fidelity:maxValue;
sigy = sigx.';
VM = (1/(sqrt(2)) .* sqrt((sigx-sigy).^2 + (sigy).^2 +(-sigx).^2));
[x,y,~] = find(VM<Yieldstr);
PStress = [sigx(y).' sigy(x)];
A = boundary(PStress,0);
plot(PStress(A,1),PStress(A,2),'LineWidth',1.75);
view(0,90);
colormap jet [X,Y,Z] = cylinder(PStress);
mesh(X,Y,Z)
view([-32.636 3.808]) Please let me know if you can think of a better way to achieve this 3d shape.
Thank you,
Kevin.

サインインしてコメントする。

### 採用された回答

Robert U 2021 年 10 月 18 日
Hi Kevin Hanekom,
it seems your vector PStress has two colums which are both interpreted as radius by the function cylinder and merged accordingly. If just one column is of interest, you would have to call it explicitely.
Yieldstr = 1000; % KPa, Sets the str for all following 2d Plots
minValue = -4*Yieldstr;
maxValue = 4*Yieldstr;
fidelity = Yieldstr/125; %able to use much higher fidelity in 2d
sigx = minValue:fidelity:maxValue;
sigy = sigx.';
VM = (1/(sqrt(2)) .* sqrt((sigx-sigy).^2 + (sigy).^2 +(-sigx).^2));
[x,y,~] = find(VM<Yieldstr);
PStress = [sigx(y).' sigy(x)];
A = boundary(PStress,0);
plot(PStress(A,1),PStress(A,2),'LineWidth',1.75);
view(0,90);
colormap jet [X,Y,Z] = cylinder(PStress(:,2));
mesh(X,Y,Z)
view([-32.636 3.808]) Kind regards,
Robert
##### 1 件のコメント表示非表示 なし
Kevin Hanekom 2021 年 10 月 18 日
Amazing, Thank you!!

サインインしてコメントする。

R2021a

### Community Treasure Hunt

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

Start Hunting!