Bulding a Torus Knot matlab code (guide) phi=str2double(get(handles.edit1,'String')); q=str2double(get(handles.edit2,'String')); C=str2double(get(handles.edit3,'String')) theta=linspace(0,2*pi,200); r=cos(q.*theta)+2; x=r.*(cos(phi.*theta)); y=r.*(sin(phi.*theta)); z=-(sin(q.*theta)); C=min((phi-1).*q,(q-1).*phi) %%crossing number (r-2).^2+z.^2==1; axis(handles.axes1) cla plot3(x,y,z,'-y','LineWidth',2); axis equal axis off rotate3d on xlabel('X','fontSize',14); ylabel('Y','fontSize',14); zlabel('Z','fontsize',14); title('Torus knot','fontsize',15)