-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo2.m
More file actions
1141 lines (916 loc) · 44.4 KB
/
Demo2.m
File metadata and controls
1141 lines (916 loc) · 44.4 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% Nima Ghaviha (nima.ghaviha@mdh.se)
% 2016-10-17
% The function for the offline calculation GUI.
function varargout = Demo2(varargin)
% DEMO2 MATLAB code for Demo2.fig
% DEMO2, by itself, creates a new DEMO2 or raises the existing
% singleton*.
%
% H = DEMO2 returns the handle to a new DEMO2 or the handle to
% the existing singleton*.
%
% DEMO2('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DEMO2.M with the given input arguments.
%
% DEMO2('Property','Value',...) creates a new DEMO2 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Demo2_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Demo2_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help Demo2
% Last Modified by GUIDE v2.5 18-Jul-2016 11:35:41
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Demo2_OpeningFcn, ...
'gui_OutputFcn', @Demo2_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Demo2 is made visible.
function Demo2_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Demo2 (see VARARGIN)
% Choose default command line output for Demo2
handles.Accuracy = 1;
handles.pop = 1;
axes(handles.axes2);
Bombardier_Logo = imread('bombardier.jpg');
image(Bombardier_Logo);
axis off;
axes(handles.axes3);
MDH_Logo = imread('MDH-logo.jpg');
image(MDH_Logo);
axis off;
axes(handles.axes4);
MDH_Logo = imread('SICS.jpg');
image(MDH_Logo);
axis off;
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Demo2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Demo2_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes when selected object is changed in uipanel1.
function uipanel1_SelectionChangeFcn(hObject, eventdata, handles)
% hObject handle to the selected object in uipanel1
% eventdata structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
switch get(eventdata.NewValue, 'Tag')
case 'radiobutton12'
handles.Accuracy = 12;
case 'radiobutton13'
handles.Accuracy = 13;
end
guidata(hObject,handles);
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
switch handles.Accuracy
case 12
tS = str2double(handles.InputNoT);
xS = str2double(handles.InputNoX);
vS = str2double(handles.InputNoV);
case 13
tS = round(handles.TTime2 / str2double(handles.InputTstep));
xS = round(handles.TDistance2 / str2double(handles.InputXstep));
vS = round(handles.MaxSpeed2 / str2double(handles.InputVstep));
end
handles.vstep = handles.MaxSpeed2 / vS;
handles.tstep = handles.TTime2 / tS;
handles.xstep = handles.TDistance2 / xS;
handles.PlusTstep = round(handles.PlusT2 / handles.tstep);
handles.MinusTstep = round(handles.MinusT2 / handles.tstep);
handles.NoT2 = tS + handles.PlusTstep + 1;
handles.Vop = zeros(handles.NoT2, xS+1, vS + 1);
CalTime = 0;
handles.SpeedL = zeros(xS+1, 1);
handles.Elevations = zeros(xS+1, 1);
[handles.Vop, CalTime, handles.SpeedL, handles.Elevations] = main(tS, xS, vS, handles.TTime2, handles.TDistance2, handles.RRA2, handles.RRB2, handles.RRC2, handles.TrainMass2, handles.MaxTractiveEffort2, handles.MaxBrakingEffort2, handles.BreakingPoint2, handles.MaxSpeed2, handles.Elev2, handles.SL2, handles.MinusT2, handles.PlusT2, handles.ACMPower2);
set(handles.text1, 'String', num2str(CalTime));
guidata(hObject, handles);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
tic
switch handles.Accuracy
case 12
tS = str2double(handles.InputNoT);
xS = str2double(handles.InputNoX);
vS = str2double(handles.InputNoV);
%set(handles.text1, 'String', '3');
case 13
tS = round(handles.TTime2 / str2double(handles.InputTstep));
xS = round(handles.TDistance2 / str2double(handles.InputXstep));
vS = round(handles.MaxSpeed2 / str2double(handles.InputVstep));
end
handles.NoT = tS+1;
handles.NoX = xS+1;
tstep_find = handles.TTime2/tS;
xstep_find = handles.TDistance2/xS;
vstep_find = handles.MaxSpeed2/vS;
handles.InputT2 = round(str2double(handles.InputT)/tstep_find) + 1;
handles.InputX2 = round(str2double(handles.InputX)/xstep_find) + 1;
handles.InputV2 = round(str2double(handles.InputV)/vstep_find) + 1;
handles.InputX_R = str2double(handles.InputX)/xstep_find + 1;
handles.InputV_R = str2double(handles.InputV)/vstep_find + 1;
handles.Vout = zeros(handles.NoT2, 1);
handles.Xout = zeros(handles.NoT2, 1);
handles.DistOpout = zeros(handles.NoT2, 1);
handles.EffortOpout = zeros(handles.NoT2, 1);
handles.FAccOpout = zeros(handles.NoT2, 1);
handles.FROpout = zeros(handles.NoT2, 1);
handles.Eopout = zeros(handles.NoT2, 1);
handles.Gopout = zeros(handles.NoT2, 1);
handles.Current = zeros(handles.NoT2, 1);
handles.Power = zeros(handles.NoT2, 1);
handles.Loss = zeros(handles.NoT2, 1);
handles.DEnergy = 0;
handles.BEnergy = 0;
[handles.Vout, handles.Xout, handles.DistOpout, handles.EffortOpout, handles.FAccOpout, handles.FROpout, handles.Eopout, handles.Gopout, handles.Loss, handles.DEnergy, handles.BEnergy, handles.Power, handles.Current] = find_n(handles.Vop, tS, xS, vS, handles.InputT2, handles.InputX2, handles.InputX_R, handles.InputV2, handles.InputV_R, handles.TTime2, handles.TDistance2, handles.MaxSpeed2, handles.MinusT2, handles.PlusT2, handles.SpeedL, handles.Elevations, handles.RRA2, handles.RRB2, handles.RRC2, handles.TrainMass2, handles.ACMPower2, handles.MaxTractiveEffort2, handles.MaxBrakingEffort2, handles.BreakingPoint2);
set(handles.text44, 'String', num2str(handles.DEnergy));
set(handles.text45, 'String', num2str(handles.BEnergy));
ETotal = handles.BEnergy + handles.DEnergy;
set(handles.text54, 'String', num2str(ETotal));
set(handles.text34, 'String', num2str(handles.EffortOpout(handles.InputT2)/1000));
toc
set(handles.text2, 'String', 'Done!');
axes(handles.axes1);
PlotX = (1:handles.NoX);
PlotElev = adjust_elevations(handles.TDistance2, xstep_find, handles.Elev2);
PlotSpeed = adjust_speed(handles.TDistance2, xstep_find, handles.SL2);
plot((handles.Xout - 1) * handles.xstep, (handles.Vout - 1)*handles.vstep, 'b-*', (PlotX - 1) * handles.xstep, PlotSpeed, 'r:', (PlotX - 1) * handles.xstep, PlotElev, 'k--');
xlabel('Distance[m]');
ylabel('Velocity[Km/h]');
title('Velocity - Distance');
figure(12)
plot((handles.Xout - 1) * handles.xstep, (handles.Vout - 1)*handles.vstep, 'b-*', (PlotX - 1) * handles.xstep, PlotSpeed, 'r:', (PlotX - 1) * handles.xstep, PlotElev, 'k--');
xlabel('Distance[m]');
ylabel('Velocity[Km/h]');
title('Velocity - Distance');
guidata(hObject,handles);
function TripTime_Callback(hObject, eventdata, handles)
% hObject handle to TripTime (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.TTime = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of TripTime as text
% str2double(get(hObject,'String')) returns contents of TripTime as a double
% --- Executes during object creation, after setting all properties.
function TripTime_CreateFcn(hObject, eventdata, handles)
% hObject handle to TripTime (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function TripDistance_Callback(hObject, eventdata, handles)
% hObject handle to TripDistance (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.TDistance = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of TripDistance as text
% str2double(get(hObject,'String')) returns contents of TripDistance as a double
% --- Executes during object creation, after setting all properties.
function TripDistance_CreateFcn(hObject, eventdata, handles)
% hObject handle to TripDistance (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in SL_Open.
function SL_Open_Callback(hObject, eventdata, handles)
% hObject handle to SL_Open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[sl, SL_path] = uigetfile('*.xlsx', 'Selcet Speed Limits file');
set(handles.text36, 'String', sl);
handles.SL = strcat(SL_path, sl);
guidata(hObject, handles);
% --- Executes on button press in Elev_Open.
function Elev_Open_Callback(hObject, eventdata, handles)
% hObject handle to Elev_Open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[elev, Elev_path] = uigetfile('*.xlsx', 'Select Elevations file');
set(handles.text38, 'String', elev);
handles.Elev = strcat(Elev_path, elev);
guidata(hObject, handles);
% --- Executes on button press in input.
function input_Callback(hObject, eventdata, handles)
% hObject handle to input (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.Elev2 = handles.Elev;
handles.SL2 = handles.SL;
handles.TTime2 = str2double(handles.TTime);
handles.TDistance2 = str2double(handles.TDistance) * 1000;
handles.MinusT2 = str2double(handles.MinusT);
handles.PlusT2 = str2double(handles.PlusT);
handles.RRA2 = str2double(handles.RRA);
handles.RRB2 = str2double(handles.RRB);
handles.RRC2 = str2double(handles.RRC);
handles.TrainMass2 = str2double(handles.TrainMass) * 1000;
handles.MaxTractiveEffort2 = str2double(handles.MaxTractiveEffort) * 1000;
handles.MaxBrakingEffort2 = str2double(handles.MaxBrakingEffort) * 1000;
handles.BreakingPoint2 = str2double(handles.BreakingPoint);
handles.MaxSpeed2 = str2double(handles.MaxSpeed);
handles.ACMPower2 = str2double(handles.ACMPower);
if isnan(handles.MinusT2)
handles.MinusT2 = 0;
end
if isnan(handles.PlusT2)
handles.PlusT2 = 0;
end
if isnan(handles.RRA2)
handles.RRA2 = 2222;
end
if isnan(handles.RRB2)
handles.RRB2 = 5.25;
end
if isnan(handles.RRC2)
handles.RRC2 = 0.508;
end
if isnan(handles.TrainMass2)
handles.TrainMass2 = 184110;
end
if isnan(handles.MaxTractiveEffort2)
handles.MaxTractiveEffort2 = 100000;
end
if isnan(handles.MaxBrakingEffort2)
handles.MaxBrakingEffort2 = 100000;
end
if isnan(handles.BreakingPoint2)
handles.BreakingPoint2 = 40;
end
if isnan(handles.MaxSpeed2)
handles.MaxSpeed2 = 80;
end
if isnan(handles.ACMPower2)
handles.MaxSpeed2 = 80;
end
guidata(hObject,handles);
function RRA_Callback(hObject, eventdata, handles)
% hObject handle to RRA (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.RRA = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of RRA as text
% str2double(get(hObject,'String')) returns contents of RRA as a double
% --- Executes during object creation, after setting all properties.
function RRA_CreateFcn(hObject, eventdata, handles)
% hObject handle to RRA (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function RRB_Callback(hObject, eventdata, handles)
% hObject handle to RRB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.RRB = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of RRB as text
% str2double(get(hObject,'String')) returns contents of RRB as a double
% --- Executes during object creation, after setting all properties.
function RRB_CreateFcn(hObject, eventdata, handles)
% hObject handle to RRB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function RRC_Callback(hObject, eventdata, handles)
% hObject handle to RRC (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.RRC = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of RRC as text
% str2double(get(hObject,'String')) returns contents of RRC as a double
% --- Executes during object creation, after setting all properties.
function RRC_CreateFcn(hObject, eventdata, handles)
% hObject handle to RRC (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function TrainMass_Callback(hObject, eventdata, handles)
% hObject handle to TrainMass (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.TrainMass = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of TrainMass as text
% str2double(get(hObject,'String')) returns contents of TrainMass as a double
% --- Executes during object creation, after setting all properties.
function TrainMass_CreateFcn(hObject, eventdata, handles)
% hObject handle to TrainMass (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function MaxTractiveEffort_Callback(hObject, eventdata, handles)
% hObject handle to MaxTractiveEffort (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.MaxTractiveEffort = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of MaxTractiveEffort as text
% str2double(get(hObject,'String')) returns contents of MaxTractiveEffort as a double
% --- Executes during object creation, after setting all properties.
function MaxTractiveEffort_CreateFcn(hObject, eventdata, handles)
% hObject handle to MaxTractiveEffort (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function MaxBrakingEffort_Callback(hObject, eventdata, handles)
% hObject handle to MaxBrakingEffort (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.MaxBrakingEffort = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of MaxBrakingEffort as text
% str2double(get(hObject,'String')) returns contents of MaxBrakingEffort as a double
% --- Executes during object creation, after setting all properties.
function MaxBrakingEffort_CreateFcn(hObject, eventdata, handles)
% hObject handle to MaxBrakingEffort (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function BreakingPoint_Callback(hObject, eventdata, handles)
% hObject handle to BreakingPoint (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.BreakingPoint = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of BreakingPoint as text
% str2double(get(hObject,'String')) returns contents of BreakingPoint as a double
% --- Executes during object creation, after setting all properties.
function BreakingPoint_CreateFcn(hObject, eventdata, handles)
% hObject handle to BreakingPoint (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function MaxSpeed_Callback(hObject, eventdata, handles)
% hObject handle to MaxSpeed (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.MaxSpeed = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of MaxSpeed as text
% str2double(get(hObject,'String')) returns contents of MaxSpeed as a double
% --- Executes during object creation, after setting all properties.
function MaxSpeed_CreateFcn(hObject, eventdata, handles)
% hObject handle to MaxSpeed (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.pop = get(handles.popupmenu2,'value');
guidata(hObject, handles);
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
plot_time = (handles.InputT2 : handles.NoT2);
V_plot = zeros(handles.NoT2 - handles.InputT2, 1);
X_plot = zeros(handles.NoT2 - handles.InputT2, 1);
Fa_plot = zeros(handles.NoT2 - handles.InputT2, 1);
Ft_plot = zeros(handles.NoT2 - handles.InputT2, 1);
E_plot = zeros(handles.NoT2 - handles.InputT2, 1);
Power_plot = zeros(handles.NoT2 - handles.InputT2, 1);
Current_plot = zeros(handles.NoT2 - handles.InputT2, 1);
Loss_plot = zeros(handles.NoT2 - handles.InputT2, 1);
for i = handles.InputT2 : handles.NoT2
V_plot(i - handles.InputT2 + 1) = handles.Vout(i);
X_plot(i - handles.InputT2 + 1) = handles.Xout(i);
Fa_plot(i - handles.InputT2 + 1) = handles.FAccOpout(i);
Ft_plot(i - handles.InputT2 + 1) = handles.EffortOpout(i);
E_plot(i - handles.InputT2 + 1) = handles.Eopout(i);
Power_plot(i - handles.InputT2 + 1) = handles.Power(i);
Current_plot(i - handles.InputT2 + 1) = handles.Current(i);
Loss_plot(i - handles.InputT2 + 1) = handles.Loss(i);
end
switch handles.pop
case 1
figure(1)
plot((plot_time - 1) * handles.tstep , (V_plot - 1)*handles.vstep, 'b-*');
xlabel('Time[s]');
ylabel('Velocity[km/h]');
title('Velocity - Time');
grid on;
case 2
figure(2)
xlabel('Time[s]');
ylabel('Distance[m]');
title('Distance - Time');
plot((plot_time - 1) * handles.tstep, (X_plot - 1) * handles.xstep, 'b-*');
grid on;
case 3
figure(3)
xlabel('Time[s]');
ylabel('TractiveEffort[kN]');
title('TractiveEffort - Time');
plot((plot_time - 1) * handles.tstep, Ft_plot / 1000, 'b-*');
grid on;
case 4
figure(4)
xlabel('Time[s]');
ylabel('Acceleration Rate[m/(s^2)]');
title('Acceleration Rate - Time');
plot((plot_time - 1) * handles.tstep, Fa_plot*1000/handles.TrainMass2, 'b-*');
grid on;
case 5
figure(5)
plot((handles.Xout - 1) * handles.xstep, (V_plot - 1)*handles.vstep, 'b-*');
xlabel('Distance[m]');
ylabel('Velocity[km/h]');
title('Velocity - Distance');
grid on;
case 6
figure(6)
plot((V_plot - 1)*handles.vstep, Ft_plot / 1000, 'b-*');
xlabel('Velocity[km/h]');
ylabel('TractiveEffort[kN]');
title('TractiveEffort - Velocity');
grid on;
case 7
figure(7)
plot((handles.Xout - 1) * handles.xstep, handles.EffortOpout / 1000, 'b-*');
xlabel('Distance[m]');
ylabel('TractiveEffort[KN]');
title('Distance/TractiveEffort');
grid on;
case 8
figure(8)
plot((plot_time - 1) * handles.tstep, E_plot, 'b-*');
xlabel('Time[s]');
ylabel('Energy[J]');
title('Time/Energy');
grid on;
case 9
AccumulativeE = zeros(handles.NoT2, 1);
AccumulativeE(2, 1) = handles.Eopout(1,1);
for count = 3 : handles.NoT2
AccumulativeE(count, 1) = AccumulativeE(count - 1, 1) + handles.Eopout(count - 1, 1);
end
PlotT = (1:handles.NoT2);
figure(9)
plot((PlotT - 1) * handles.tstep, AccumulativeE * 2.777778 * (10^(-7)), 'b-*');
xlabel('Time[s]');
ylabel('Total Energy[KwH]');
title('Time/Total Energy');
grid on;
case 10
PlotX = (1:handles.NoX);
figure(10)
plot((X_plot - 1) * handles.xstep, Ft_plot / 1000, 'b-*', (PlotX - 1) * handles.xstep, handles.SpeedL, 'k:', (PlotX - 1) * handles.xstep, handles.Elevations, 'k--');
xlabel('Distance[m]');
ylabel('Tractive Effort[kN]');
title('Tractive Effort - Distance');
grid on;
case 11
figure(14)
plot((X_plot - 1) * handles.xstep, Power_plot / 1000, 'b-*');
xlabel('Distance[m]');
ylabel('Power[kW]');
title('Power - Distance');
grid on;
case 12
figure(15)
plot((V_plot - 1)*handles.vstep, Power_plot / 1000, 'b-*');
xlabel('Velocity[km/h]');
ylabel('Power[kW]');
title('Velocity - Power');
grid on;
case 13
figure(16)
plot((plot_time - 1) * handles.tstep, Power_plot / 1000, 'b-*');
xlabel('Time[s]');
ylabel('Power[kW]');
title('Power - Time');
grid on;
case 14
figure(17)
plot((plot_time - 1) * handles.tstep, Current_plot / 1000, 'b-*');
xlabel('Time[s]');
ylabel('Current[kA]');
title('Current - Time');
grid on;
case 15
figure(18)
plot((plot_time - 1) * handles.tstep, Loss_plot , 'b-*');
xlabel('Time[s]');
ylabel('Loss[?]');
title('Loss - Time');
grid on;
case 16
figure(19)
plot((V_plot - 1)*handles.vstep, Loss_plot, 'b-*');
xlabel('Velocity[km/h]');
ylabel('Loss[?]');
title('Velocity - Loss');
grid on;
case 17
figure(20)
plot(Ft_plot / 1000, Loss_plot, 'b-*');
xlabel('Tractive Effort[kN]');
ylabel('Loss[?]');
title('Velocity - Loss');
grid on;
end
guidata(hObject,handles);
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
switch handles.Accuracy
case 12
tS = str2double(handles.InputNoT);
xS = str2double(handles.InputNoX);
vS = str2double(handles.InputNoV);
case 13
tS = round(handles.TTime2 / str2double(handles.InputTstep));
xS = round(handles.TDistance2 / str2double(handles.InputXstep));
vS = round(handles.MaxSpeed2 / str2double(handles.InputVstep));
end
[Show_FileName, Show_FilePath] = uiputfile('*.xlsx', 'save results as');
Show_File = strcat(Show_FilePath, Show_FileName);
Energy = handles.DEnergy + handles.BEnergy + (handles.ACMPower2 * handles.TTime2 / 3600);
tempo = Exc(handles.Vout, handles.Xout, handles.DistOpout, handles.EffortOpout, handles.FAccOpout, handles.FROpout, handles.Eopout, handles.Gopout, Show_File, tS, handles.tstep, handles.xstep, handles.vstep, Energy);
winopen(Show_File);
guidata(hObject, handles);
function InputT_Callback(hObject, eventdata, handles)
% hObject handle to InputT (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.InputT = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of InputT as text
% str2double(get(hObject,'String')) returns contents of InputT as a double
% --- Executes during object creation, after setting all properties.
function InputT_CreateFcn(hObject, eventdata, handles)
% hObject handle to InputT (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function InputX_Callback(hObject, eventdata, handles)
% hObject handle to InputX (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.InputX = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of InputX as text
% str2double(get(hObject,'String')) returns contents of InputX as a double
% --- Executes during object creation, after setting all properties.
function InputX_CreateFcn(hObject, eventdata, handles)
% hObject handle to InputX (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function InputV_Callback(hObject, eventdata, handles)
% hObject handle to InputV (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.InputV = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of InputV as text
% str2double(get(hObject,'String')) returns contents of InputV as a double
% --- Executes during object creation, after setting all properties.
function InputV_CreateFcn(hObject, eventdata, handles)
% hObject handle to InputV (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function inputNoT_Callback(hObject, eventdata, handles)
% hObject handle to inputNoT (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.InputNoT = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of inputNoT as text
% str2double(get(hObject,'String')) returns contents of inputNoT as a double
% --- Executes during object creation, after setting all properties.
function inputNoT_CreateFcn(hObject, eventdata, handles)
% hObject handle to inputNoT (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function inputNoX_Callback(hObject, eventdata, handles)
% hObject handle to inputNoX (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.InputNoX = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of inputNoX as text
% str2double(get(hObject,'String')) returns contents of inputNoX as a double
% --- Executes during object creation, after setting all properties.
function inputNoX_CreateFcn(hObject, eventdata, handles)
% hObject handle to inputNoX (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function inputNoV_Callback(hObject, eventdata, handles)
% hObject handle to inputNoV (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.InputNoV = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of inputNoV as text
% str2double(get(hObject,'String')) returns contents of inputNoV as a double
% --- Executes during object creation, after setting all properties.
function inputNoV_CreateFcn(hObject, eventdata, handles)
% hObject handle to inputNoV (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit17_Callback(hObject, eventdata, handles)
% hObject handle to edit17 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.MinusT = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of edit17 as text
% str2double(get(hObject,'String')) returns contents of edit17 as a double
% --- Executes during object creation, after setting all properties.
function edit17_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit17 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit18_Callback(hObject, eventdata, handles)
% hObject handle to edit18 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.PlusT = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of edit18 as text
% str2double(get(hObject,'String')) returns contents of edit18 as a double
% --- Executes during object creation, after setting all properties.
function edit18_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit18 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit19_Callback(hObject, eventdata, handles)
% hObject handle to edit19 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.InputTstep = get(hObject, 'String');
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of edit19 as text
% str2double(get(hObject,'String')) returns contents of edit19 as a double
% --- Executes during object creation, after setting all properties.
function edit19_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit19 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end