-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlaserProfile.m
51 lines (43 loc) · 1.39 KB
/
laserProfile.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
classdef laserProfile
% Defines a laser object
properties
param;
omega;
totalTime;
dt;
isGaussian;
time;
amplitude;
end
methods
function obj = laserProfile(param, omega, t, dt, gaussian)
obj.param = param;
obj.omega = omega;
obj.totalTime = t;
obj.dt = dt;
obj.isGaussian = gaussian;
obj.time = linspace(0,2*obj.totalTime,2*obj.totalTime/obj.dt);
if gaussian
obj.amplitude = exp(-param*(obj.time-obj.totalTime).^2);
else
obj.amplitude = 1/pi * param/(param^2+(obj.time-obj.totalTime).^2);
end
obj.amplitude = pi/trapz(obj.amplitude) .* obj.amplitude .* cos(omega*(obj.time-obj.totalTime));
obj.amplitude = obj.amplitude./obj.dt;
end
function obj = plot(obj)
fig = figure;
plot(obj.time, obj.amplitude);
ylabel('Amplitude');
xlabel('Time');
title('Laser Profile');
if obj.isGaussian
file_name = 'gaussian';
else
file_name = 'Lorentzian';
end
file_name = [file_name '_' num2str(obj.param) '_' num2str(obj.omega) '_matlab.png'];
saveas(fig,file_name);
end
end
end