Error trying to draw a spline

1 view (last 30 days)
Cedrick Levesque-Baker
Cedrick Levesque-Baker on 2 Feb 2016
Hi,
I am trying to dray the blue line on the image below on matlab based on the geometry of the t-joint. I use coordinate iteration and spline fct to do so. I don't know why but I can't get it to work properly. Can you enlight me ?
Thanks,
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 = -D/2:((D/2)+l2);
y = -l1/2 :l1/2;
z = -D/2: D/2;
%Variable Definition
r = D/2;
%Winding step one
for y=-r-l2:0.01:0;
x = (-(r+l2)/r);
z = sqrt((r.^2)-(x.^2));
xyz = [x ; y ; z];
%can be erased to remove points
hold on;
fnplt(cscvn(xyz(:,[1:end 1])),'r',2);
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);
  2 Comments
Walter Roberson
Walter Roberson on 2 Feb 2016
Are you encountering an error message?
Cedrick Levesque-Baker
Cedrick Levesque-Baker on 2 Feb 2016
Hi Walter, it says that imaginary number have been discard, which should not happen and the output is straight spline
this line seems to be the error : z = sqrt((r.^2)-(x.^2));

Sign in to comment.

Answers (1)

Cedrick Levesque-Baker
Cedrick Levesque-Baker on 3 Feb 2016
I finally found my mistakes and they were pretty obvious, I was just not paying attention enough. Here it is if it can be useful to someone.
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);

Community Treasure Hunt

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

Start Hunting!