Code covered by the BSD License  

Highlights from
3D Helical solenoid

image thumbnail

3D Helical solenoid

by

 

18 Mar 2013 (Updated )

Example of a 3D helical solenoid

helical_solenoid.m
clear all;
close all;

%% Helix parameters
% helix radius
R=5;

% heigth
h=10;

% turns
nh=2;

%% Solenoid parameters
% solenoid turns per helix turn
ns=50;

% solenoid radius
r=1;

%%
% domain
t = 0:0.0001:2*pi;

h=h/(2*pi);

%% helix equation
xg=R*cos(nh*t);
yg=R*sin(nh*t);
zg=h*t;

%% helical solenoid equation
xs = (r*cos(ns*nh*t)+R).*cos(nh*t);
ys = (r*cos(ns*nh*t)+R).*sin(nh*t);
zs = r*sin(ns*nh*t)+h*t;

%% Plot
figure
axis equal
hold on
plot3(xg,yg,zg,'r');
plot3(xs,ys,zs,'b');
hold off
grid on
xlabel('x');ylabel('y');zlabel('z');title('helical solenoid');

Contact us