-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCBaseSolution.m
40 lines (37 loc) · 1.01 KB
/
CBaseSolution.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
classdef CBaseSolution
%CMesh
% Brief: Base class for time solutions
% Author: S.Ramon
% Version: 0.0.1
properties
potentialEnergy
kineticEnergy
t
end
properties (Dependent)
totalEnergy
end
methods
function result = get.totalEnergy( object )
result = object.potentialEnergy + object.kineticEnergy;
end
function plotEnergy( object )
figure
o = object;
plot(o.t,o.potentialEnergy,o.t,o.kineticEnergy,o.t,o.totalEnergy);
title('Energy')
xlabel('t[s]')
ylabel('Energy[J]')
legend('Potential','Kinetic','Total')
end
function plotError( object, ModalSolution )
figure
o = object;
error = abs(o.totalEnergy-ModalSolution.totalEnergy)./ModalSolution.totalEnergy;
plot(o.t,error);
title('Error')
xlabel('t[s]')
ylabel('Error')
end
end
end