Matlab 圆柱上的花键
我试图根据t型接头的几何结构,在matlab上绘制下图中的蓝线。我使用坐标迭代和样条fct来实现。我不知道为什么,但我不能让它正常工作。你能启发我吗 谢谢 清除所有; clcMatlab 圆柱上的花键,matlab,plot,spline,Matlab,Plot,Spline,我试图根据t型接头的几何结构,在matlab上绘制下图中的蓝线。我使用坐标迭代和样条fct来实现。我不知道为什么,但我不能让它正常工作。你能启发我吗 谢谢 清除所有; clc 睡了一夜好觉后,我自己发现了我的错误,很明显,我只是在我使用的方程式上犯了一个错误。这里是更正的代码,如果它对某人有用的话 clear all; clc; %TJoint Winding w/o radius %The idea is to experiment with matlab %Obtains the
睡了一夜好觉后,我自己发现了我的错误,很明显,我只是在我使用的方程式上犯了一个错误。这里是更正的代码,如果它对某人有用的话
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);
w = 'What is the width of the carbon fiber used? ';
w = input(w);
'Thank you, we are now processing the Filament winding of your T-Joint. Please wait ';
%Defining Graph size
x = -l1/2 :l1/2;
y = -D/2:((D/2)+l2);
z = -D/2: D/2;
%Variable Definition
r = D/2;
%Winding step one
for y=-r-l2:0.01:0;
x = (-r/(r+l2))*y ;
z = sqrt(r.^2-x.^2);
xyz = [x ; y ; z];
%can be erased to remove points
fnplt(cscvn(xyz(:,[1:end 1])),'r',2);
hold on;
end
%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);
睡了一夜好觉后,我自己发现了我的错误,很明显,我只是在我使用的方程式上犯了一个错误。这里是更正的代码,如果它对某人有用的话
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);
w = 'What is the width of the carbon fiber used? ';
w = input(w);
'Thank you, we are now processing the Filament winding of your T-Joint. Please wait ';
%Defining Graph size
x = -l1/2 :l1/2;
y = -D/2:((D/2)+l2);
z = -D/2: D/2;
%Variable Definition
r = D/2;
%Winding step one
for y=-r-l2:0.01:0;
x = (-r/(r+l2))*y ;
z = sqrt(r.^2-x.^2);
xyz = [x ; y ; z];
%can be erased to remove points
fnplt(cscvn(xyz(:,[1:end 1])),'r',2);
hold on;
end
%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);
我假设请求输入的初始行与您的问题无关。请用一些常量替换它们。这可以防止任何人在选择错误的参数时产生额外的问题。“我不知道为什么,但我不能让它正常工作。”什么不起作用?代码是否运行?它有输出吗?输出是否正确?你怎么知道的?如果没有这些重要的信息,你的问题很难回答。嗨,大卫,很抱歉说得不够清楚。问题似乎出现在z=sqrt(r.^2-x.^2);我得到警告:警告:复数X,Y和/或Z参数的虚部被忽略>在fnplt中237在Twinding_revb中37(第37行是fnplt(cscvn(xyz(:,[1:end 1]),'r',2);)我不明白为什么,这似乎是我的方程中的一个错误,但我没有看到我的错误。thanksI假设请求输入的初始行与您的问题无关。请用一些常量替换它们。这可以防止任何人在选择错误的参数时产生额外的问题。“我不知道为什么,但我不能让它正常工作。”什么不起作用?代码是否运行?它有输出吗?输出是否正确?你怎么知道的?如果没有这些重要的信息,你的问题很难回答。嗨,大卫,很抱歉说得不够清楚。问题似乎出现在z=sqrt(r.^2-x.^2);我得到警告:警告:复数X,Y和/或Z参数的虚部被忽略>在fnplt中237在Twinding_revb中37(第37行是fnplt(cscvn(xyz(:,[1:end 1]),'r',2);)我不明白为什么,这似乎是我的方程中的一个错误,但我没有看到我的错误。谢谢