채택된 답변

Star Strider
Star Strider 2020년 3월 16일

0 개 추천

Perhaps you can adapt the solution in: fill area between two polar curves to your problem.

댓글 수: 6

Thank you very much but I've only succeeded in filling the colour with 2D, but failed with 3D. Could you please give me a hint?
My code in 2D: patch([X1 X_arc1 fliplr(X2)], [Y1 Y_arc1 fliplr(Y2)],'g');
patch([X3 X_arc2 fliplr(X4)], [Y3 Y_arc2 fliplr(Y4)],'g');
My code in 3D: patch([X_1 X_arc1_new fliplr(X_2)], [Y_1 Y_arc1_new fliplr(Y_2)], [Z_1 Z_arc1_new fliplr(Z_2)], 'g');
patch([X_3 X_arc2_new fliplr(X_4)], [Y_3 Y_arc2_new fliplr(Y_4)], [Z_3 Z_arc2_new fliplr(Z_4)], 'g');
Add figure(3) to your code:
surffcn = @(x,y,H) surf([x;x],[y;y],[zeros(size(x)); ones(size(x))*H]); % Plots Surfaces
H = 0.5; % Height Of Sides
figure(3)
surffcn(X1,Y1,H)
hold on
surffcn(X2,Y2,H)
surffcn(X_arc1, Y_arc1,H)
surffcn(X3,Y3,H)
surffcn(X4,Y4,H)
surffcn(X5,Y5,H)
surffcn(X_arc2, Y_arc2,H)
patch([X1 X_arc1 fliplr(X2)], [Y1 Y_arc1 fliplr(Y2)],[ones(1,size(X1,2)*3)*H],'g');
patch([X3 X_arc2 fliplr(X4)], [Y3 Y_arc2 fliplr(Y4)],[ones(1,size(X3,2)*3)*H],'g');
hold off
axis('equal')
producing:
Note that you can make the height of the sides whatever you want by changing the ‘H’ value.
This only colours the upper surface. If you want to colour the lower surface as well, duplicate the two patch calls, and replace ‘H’ with 0 in only those two additional patch calls.
Thank you very much, now I want to convert it to file .stl but I don't know how. Could you please help me?
Star Strider
Star Strider 2020년 3월 16일
I have no idea how to convert it to a STL file, or even what a STL file is.
That was not part of your Question.
If it had been, I would have not have posted my Answer.
If my Answer in any way helped you solve your problem, please Accept it!
I am so sorry, I really appreciate you and your answer. Anyway, thank you so much for helping me
Star Strider
Star Strider 2020년 3월 16일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

DGM
DGM 2025년 7월 2일
편집: DGM 2025년 7월 2일

0 개 추천

I didn't notice that there were multiple questions posted on this. Here's my response to a different thread about the same project, including the STL output:

카테고리

도움말 센터File Exchange에서 Blue에 대해 자세히 알아보기

질문:

2020년 3월 16일

편집:

DGM
2025년 7월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by