Error trying to draw a spline

5 visualizaciones (últimos 30 días)
Cedrick Levesque-Baker
Cedrick Levesque-Baker el 2 de Feb. de 2016
Respondida: Cedrick Levesque-Baker el 3 de Feb. de 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 comentarios
Walter Roberson
Walter Roberson el 2 de Feb. de 2016
Are you encountering an error message?
Cedrick Levesque-Baker
Cedrick Levesque-Baker el 2 de Feb. de 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));

Iniciar sesión para comentar.

Respuestas (1)

Cedrick Levesque-Baker
Cedrick Levesque-Baker el 3 de Feb. de 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);

Categorías

Más información sobre Spline Postprocessing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by