3D plotting, Vector Length error
7 ビュー (過去 30 日間)
古いコメントを表示
Cedrick Levesque-Baker
2016 年 1 月 31 日
コメント済み: Star Strider
2016 年 1 月 31 日
Hi,
I am trying to draw a 3d shape, using equations. To do so, I use logical indexing.
I am able to do it in 2D, but not in 3d, I always get the vector length error and I do not understand why. All I am trying to do is to try a straight line from at y=0 from z=-r to z=r. If I can figure out the vector error, I will be able to move on and make more complicated things.
Thanks for your help.
clear all;
clc;
%TJoint Winding w/o radius
%The idea is to experiment with matlab
%Obtains the values
D = 'What is the diameter of the t joint? ';
D = input(D);
l1 = 'What is the length 1 of the t joint? ';
l1 = input(l1);
l2 = 'What is the length 2 of the t joint? ';
l2 = input(l2);
'Thank you, we are now processing the Filament winding of your T-Joint. Please wait ';
%Defining Graph size
x = -D/2:((D/2)+l2);
y = -l1/2 :l1/2;
z = -D/2: D/2;
%Variable Definition
r = D/2;
%Winding step one
x(z >= -r, z <= r ) = r+l2;
y(z >= -r, z <= r )= 0 ;
plot3(x,y,z);
%Axis Labeling
xlabel('X Axis','FontSize',14);
ylabel('Y Axis','FontSize',14);
zlabel('Z Axis','FontSize',14);
title('Tjoint winding w/o radii','FontSize',14);
0 件のコメント
採用された回答
Star Strider
2016 年 1 月 31 日
You need to do the same to z as you did to x and y:
x(z >= -r, z <= r ) = r+l2;
y(z >= -r, z <= r )= 0 ;
z(z >= -r, z <= r ) = ???;
The same conditions have to apply to all vectors for them to be of equivalent length, and for that matter, for them to have corresponding values at each point. I’m not sure what you want z to be, so I will leave that to you to define.
2 件のコメント
Star Strider
2016 年 1 月 31 日
My pleasure.
That is actually much easier.
See if this does what you want:
D = 15; % Create Data
l2 = 2; % Create Data
r = D/2;
x = [r+l2 r+l2];
y = [0 0];
z = [-r +r];
figure(1)
plot3(x, y, z)
grid on
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!