Error using patch Value must be of numeric type and greater than 1.

8 次查看(过去 30 天)
Hi, i need to figure some stl files and it's giving me an error
Error using patch
Value must be of numeric type and greater than 1.
Error in rysujPATCH (line 63)
czlon11=patch('Faces',C11.Faces,'Vertices',C11.Vertices,'FaceColor',C11.FaceColor);
matrixes are included
this is the code
%%
% Rysuj czlony
P2=C2.Vertices';
Unable to resolve the name 'C2.Vertices'.
P3=C3.Vertices';
% ustawianie czlonow
P2=F12(0)*[P2; ones(1, size(P2, 2))];
%
C2R=C2;
%
C2R.Vertices=P2(1:3,1:size(P2, 2))';
%
P3=F12(0)*F23(0)*[P3;ones(1,size(P3, 2))];
%
C3R=C3;
C3R.Vertices=P3(1:3,1:size(P3, 2))';
%% rysowanie
figure(1);
axis([-100,400,-100,400,-100,700]);
grid on;
hold on;
%
czlon11=patch('Faces',C11.Faces,'Vertices',C11.Vertices,'FaceColor',C11.FaceColor);
%%
%czlon12=patch(C12);
czlon12=patch('Faces',C12.Faces,'Vertices',C12.Vertices,'FaceColor',C12.FaceColor);
%
%czlon2=patch(C2R);
czlon2=patch('Faces',C2R.Faces,'Vertices',C2R.Vertices,'FaceColor',C2.FaceColor);
%
%czlon3=patch(C3R);
czlon3=patch('Faces',C3R.Faces,'Vertices',C3R.Vertices,'FaceColor',C3.FaceColor);
clear P2 P3 C2R C3R
I've already add +1 to whole faces matrix and still no luck.
Please help
EDIT: I've exported the stl files from SOLIDWORKS 2024
  6 个评论
TheIOzikI
TheIOzikI 2024-1-20
function [C]=C12(fi2)
C=[cos(fi2) -sin(fi2) 0;
0 0 -1;
sin(fi2) cos(fi2) 0];
function [C]=C23(fi3)
C=[cos(fi3) -sin(fi3) 0;
sin(fi3) cos(fi3) 0;
0 0 1];

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2024-1-20
编辑:Star Strider 2024-1-20
I was not able to get these to work with patch (I still do not understand what that problem is), however with a minor modification, I was able to get them to work with the trisurf function —
load('matrixes.mat')
whos
Name Size Bytes Class Attributes C11 1x1 2448 struct C12 1x1 29352 struct C2 1x1 30960 struct C3 1x1 30960 struct ans 1x37 74 char cmdout 1x33 66 char
% [vl,vu] = bounds(C11.Vertices)
% [r,c] = size(C11.Faces)
% [vl,vu] = bounds(C12.Vertices)
% [r,c] = size(C12.Faces)
% [vl,vu] = bounds(C2.Vertices)
% [r,c] = size(C2.Faces)
% [vl,vu] = bounds(C3.Vertices)
% [r,c] = size(C3.Faces)
figure
trisurf(C11.Vertices-1, C11.Faces(:,1), C11.Faces(:,2), C11.Faces(:,3), 'FaceColor',C11.FaceColor)%, 'EdgeColor',C11.FaceColor)
title('C11')
figure
trisurf(C12.Vertices-1, C12.Faces(:,1), C12.Faces(:,2), C12.Faces(:,3), 'FaceColor',C12.FaceColor)%, 'EdgeColor',C12.FaceColor)
title('C12')
figure
trisurf(C2.Vertices-1, C2.Faces(:,1), C2.Faces(:,2), C2.Faces(:,3), 'FaceColor',C2.FaceColor)%, 'EdgeColor',C2.FaceColor)
title('C2')
figure
trisurf(C3.Vertices-1, C3.Faces(:,1), C3.Faces(:,2), C3.Faces(:,3), 'FaceColor',C3.FaceColor)%, 'EdgeColor',C3.FaceColor)
title('C3')
EDIT — (20 Jan 2024 at 15:16)
Experimenting with the surface lighting —
figure
trisurf(C11.Vertices-1, C11.Faces(:,1), C11.Faces(:,2), C11.Faces(:,3), 'FaceColor',C11.FaceColor, 'EdgeColor','none')
lightangle(-45, 25)
lighting('flat')
title('C11')
figure
trisurf(C12.Vertices-1, C12.Faces(:,1), C12.Faces(:,2), C12.Faces(:,3), 'FaceColor',C12.FaceColor, 'EdgeColor','none')
lightangle(-45, 25)
lighting('flat')
title('C12')
figure
trisurf(C2.Vertices-1, C2.Faces(:,1), C2.Faces(:,2), C2.Faces(:,3), 'FaceColor',C2.FaceColor, 'EdgeColor','none')
lightangle(45, 65)
lighting('flat')
title('C2')
figure
trisurf(C3.Vertices-1, C3.Faces(:,1), C3.Faces(:,2), C3.Faces(:,3), 'FaceColor',C3.FaceColor, 'EdgeColor','none')
lightangle(45, 65)
lighting('flat')
title('C3')
.
  4 个评论
TheIOzikI
TheIOzikI 2024-1-20
That worked thanks. I'm quite new in matlab. I've other issue but that needs next ticket
Star Strider
Star Strider 2024-1-20
Experiment with the lightangle arguments to get the result you want —
load('matrixes.mat');
figure
trisurf(C11.Vertices-1, C11.Faces(:,1), C11.Faces(:,2), C11.Faces(:,3), 'FaceColor',C11.FaceColor, 'EdgeColor','none')
hold on
trisurf(C12.Vertices-1, C12.Faces(:,1), C12.Faces(:,2), C12.Faces(:,3), 'FaceColor',C12.FaceColor, 'EdgeColor','none')
trisurf(C2.Vertices-1, C2.Faces(:,1), C2.Faces(:,2), C2.Faces(:,3), 'FaceColor',C2.FaceColor, 'EdgeColor','none')
trisurf(C3.Vertices-1, C3.Faces(:,1), C3.Faces(:,2), C3.Faces(:,3), 'FaceColor',C3.FaceColor, 'EdgeColor','none')
lightangle(45, 65)
lighting('flat')
% material('metal')
hold off
axis('equal')
view(-45, 20)
Ax = gca;
Ax.Visible = 0;
sgtitle('Assembled Segments')
.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop uifigure-Based Apps 的更多信息

标签

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by