-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimplot.m
More file actions
53 lines (41 loc) · 1.69 KB
/
simplot.m
File metadata and controls
53 lines (41 loc) · 1.69 KB
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
49
50
51
function simplot( data,vect,struct , Np)
% SIMPLOT create a subplot figure with data types given in input. It uses
% the Struct_array global variable created by the Data_reader file. So run
% this script before.
%
% * DATA is a cell array of the data you want to display (x,y,yaw... )
% * VECT is the vector from where you want to get the data (input, output, ref... )
% * STRUCT is a cell array of the names of the simulation that you want to
% display (HIL, SIL) several simulation data can be print in same time
% for camparaison
% * Np is an optional variable. It is the number of point you want to
% display. By default it is the maximum
global Struct_array
for i=1:length(data)
sizeArray =zeros(1,length(struct)+2) ;
for j=1:length(struct)
array = Struct_array.(struct{j}).(vect).(data{i}) ;
sizeArray(j) = length(array) ;
end
sizeArray(j+1) = length(Struct_array.(struct{j}).time) ;
if ~exist('Np','var')
% third parameter does not exist, so default it to something
Np = length(Struct_array.(struct{j}).time);
end
sizeArray(j+2) = Np ;
N=min(sizeArray) ;
subplot(length(data),1,i)
for j=1:length(struct)
array = Struct_array.(struct{j}).(vect).(data{i}) ;
plot(Struct_array.(struct{j}).time(1:N),array(1:N))
hold on
%legend(struct{j}) ;
end
% plot(Struct_array.(struct{1}).time,findfield(Struct_array.(struct{1}).(vect),data{i}))
% hold on
% plot(Struct_array.(struct{2}).time,findfield(Struct_array.(struct{2}).(vect),data{i}))
ylabel(data{i})
% legend(struct{1},struct{2})
% %end
end
end