-
Notifications
You must be signed in to change notification settings - Fork 0
/
matpplane.m
6781 lines (6021 loc) · 226 KB
/
matpplane.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
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
function output = matpplane(action,input1,input2,input3)
% matpplane is an interactive tool for studying planar autonomous
% systems of differential equations. When matpplane is executed, a
% matpplane Setupwindow is opened. The user may enter the differential
% equation and specify a display window using the interactive
% controls in the Setup window. Up to 4 parameters may also be
% specified. In addition the user is give a choice of the type of
% field displayed and the number of field points.
%
% When the Proceed button is pressed on the Setup window, the matpplane
% Display window is opened, and a field of the type requested is
% displayed for the system. When the mouse button is depressed in
% the matpplane Display window, the solution to the system with that
% initial condition is calculated and plotted.
%
% Other options are available in the menus. These are
% fairly self-explanatory.
%
% Copyright (c) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003
% John C. Polking, Rice University
% Last Modified: April 24, 2003
% Modified by JDM Nov 2016 for Matlab 2016.
% Modified by Nathanael Kazmierczak Jan 2021 for Matlab 2021.
% Modified by Roy Goodman Jan 2021 for Matlab 2020b
startstr = 'matpplane';
if nargin < 1
action ='initialize';
end
%if get(0,'screendepth') == 1
% style = 'bw';
%end
if strcmp(action,'initialize')
% First thing that runs when the program starts
% First we make sure that there is no other copy of matpplane
% running, since this causes problems.
pph = findobj('tag','matpplane');
if ~isempty(pph)
qstring = {'There are some matpplane figures open although they may be invisible. ';...
'What do you want to do?'};
tstring = 'Only one copy of matpplane can be open at one time.';
b1str = 'Restart matpplane.';
b2str = 'Just close those figures.';
b3str = 'Do nothing.';
answer = questdlg(qstring,tstring,b1str,b2str,b3str,b1str);
if strcmp(answer,b1str)
delete(pph);
%matpplane;return
eval(startstr);return
elseif strcmp(answer,b2str)
delete(pph);return
else
return
end
end % if ~isempty(pph);
% Make sure tempdir is on the MATLABPATH. We want to be sure that we
% return the path to its current position when we exit.
% p = path;
% tmpdir = tempdir;
% ll = length(tmpdir);
% tmpdir = tmpdir(1:ll-1);
ud.remtd = 0;
% The following is a more robust way to check if the operating system's
% temporary directory is on the path
pathCell = regexp(path, pathsep, 'split');
if ispc % Windows is not case-sensitive
onPath = any(strcmpi(tempdir, pathCell));
else
onPath = any(strcmp(tempdir, pathCell));
end
if ~onPath
ud.remtd = 1;
addpath(tempdir)
end
% Next we look for old files created by matpplane.
% First in the current directory.
oldfiles = dir('pptp*.m');
ofiles = cell(0,1);
% kk = zeros(0,1);
for k = 1:length(oldfiles)
fn = oldfiles(k).name;
fid = fopen(fn,'r');
fgetl(fid); %read and discard lines
fgetl(fid);
ll = fgetl(fid);
fclose(fid);
if strcmp(ll,'%% Created by matpplane')
delete(fn)
else
l= length(ofiles);
ofiles{l+1} = fn;
end
end
%Then in the temp directory.
oldfiles = dir([tempdir,'pptp*.m']);
for k = 1:length(oldfiles)
fn = [tempdir,oldfiles(k).name];
fid = fopen(fn,'r');
fgetl(fid); %read and discard lines
fgetl(fid);
ll = fgetl(fid);
fclose(fid);
if strcmp(ll,'%% Created by matpplane')
delete(fn)
else
l= length(ofiles);
ofiles{l+1} = fn;
end
end
lll = length(ofiles);
if lll >0
if lll == 1
astr = 'The file';
bstr = 'If so it can be safely deleted.';
else
astr = 'The files';
bstr = 'If so they can be safely deleted.';
end
fprintf([astr,'\n']);
for j = 1:lll
fn = ofiles{j};
disp([' ',fn]);
end
fprintf('may have been created by an older version of PPLANE.\n');
fprintf(bstr,'\n\n');
end
style = 'white';
ppdir = pwd;
ssize = get(0,'defaultaxesfontsize');
npts = 20;
solver = 'Dormand Prince';
tol = 1e-4;
stepsize = 0.1;
if exist('ppstart','file')
H = ppstart;
if ~isempty(H)
if isfield(H,'style')
style = H.style;
end
if isfield(H,'size')
ssize = H.size;
end
if isfield(H,'npts')
npts = H.npts;
end
if isfield(H,'solver')
solver = H.solver;
end
if isfield(H,'ppdir')
ppdir = H.ppdir;
end
if isfield(H,'stepsize')
stepsize = H.stepsize;
end
if isfield(H,'tolerance')
tol = H.tolerance;
end
end
end
if get(0,'screendepth') == 1
style = 'bw';
end
ud.ssize = ssize;
ud.ppdir = ppdir;
comp = computer;
if strcmp(comp,'PCWIN')
ud.fontsize = 0.8*ud.ssize;
else
ud.fontsize = ud.ssize;
end
% Set up for the menu of systems.
system.name = 'default system';
system.xvar = 'x';
system.yvar = 'y';
system.xder = ' 2*x - y + 3*(x^2-y^2) + 2*x*y';
system.yder = ' x - 3*y - 3*(x^2-y^2) + 3*x*y';
system.pname = {};
system.pval = {};
system.fieldtype = 'arrows';
system.npts = npts;
system.wind = [-2 4 -4 2];
system(2).name = 'linear system';
system(2).xvar = 'x';
system(2).yvar = 'y';
system(2).xder = ' A*x + B*y';
system(2).yder = ' C*x + D*y';
system(2).pname = {'A', 'B', 'C', 'D', '', ''};
system(2).pval = {'2', '2', '-2', '-3'};
system(2).fieldtype = 'arrows';
system(2).npts = npts;
system(2).wind = [-5 5 -5 5];
system(3).name = 'vibrating spring';
system(3).xvar = 'x';
system(3).yvar = 'v';
system(3).xder = ' v';
system(3).yder = ' -(k*x + d*v)/m';
system(3).pname = {'k', 'm', 'd', '', '', ''};
system(3).pval = {'3', '1', '0'};
system(3).fieldtype = 'arrows';
system(3).npts = npts;
system(3).wind = [-5 5 -5 5];
system(4).name = 'pendulum';
system(4).xvar = '\theta';
system(4).yvar = '\omega';
system(4).xder = ' \omega';
system(4).yder = ' -sin(\theta) - D*\omega';
system(4).pname = {'D', '', '', '', '', ''};
system(4).pval = {'0'};
system(4).fieldtype = 'arrows';
system(4).npts = npts;
system(4).wind = [-10 10 -4 4];
system(5).name = 'predator prey';
system(5).xvar = 'prey';
system(5).yvar = 'predator';
system(5).xder = ' (A - B*predator)*prey';
system(5).yder = ' (D*prey - C)*predator';
system(5).pname = {'A', 'B', 'C', 'D', '', ''};
system(5).pval = {'0.4', '0.01', '0.3', '0.005'};
system(5).fieldtype = 'arrows';
system(5).npts = npts;
system(5).wind = [0 120 0 80];
system(6).name = 'competing species';
system(6).xvar = 'x';
system(6).yvar = 'y';
system(6).xder = ' r*(1 - x - A*y)*x';
system(6).yder = ' s*(1 - y - B*x)*y';
system(6).pname = {'r', 's', 'A', 'B', '', ''};
system(6).pval = {'0.4', '0.6', '5', '4'};
system(6).fieldtype = 'nullclines';
system(6).npts = npts;
system(6).wind = [0 1 0 1];
system(7).name = 'cooperative species';
system(7).xvar = 'x';
system(7).yvar = 'y';
system(7).xder = ' r*(1 - x + A*y)*x';
system(7).yder = ' s*(1 - y + B*x)*y';
system(7).pname = {'r', 's', 'A', 'B', '', ''};
system(7).pval = {'0.4', '0.6', '2', '0.3'};
system(7).fieldtype = 'nullclines';
system(7).npts = npts;
system(7).wind = [0 9 0 5];
system(8).name = 'van der Pol''s equation';
system(8).xvar = 'x';
system(8).yvar = 'y';
system(8).xder = ' M*x - y - x^3';
system(8).yder = ' x';
system(8).pname = {'M', '', '', '', '', ''};
system(8).pval = {'2'};
system(8).fieldtype = 'arrows';
system(8).npts = npts;
system(8).wind = [-5 5 -5 5];
system(9).name = 'Duffing''s equation';
system(9).xvar = 'x';
system(9).yvar = 'y';
system(9).xder = ' y';
system(9).yder = ' -(k*x + c*y + l*x^3)/m';
system(9).pname = {'k', 'c', 'm', 'l', '', ''};
system(9).pval = {'-1', '0', '1', '1'};
system(9).fieldtype = 'arrows';
system(9).npts = npts;
system(9).wind = [-3 3 -3 3];
system(10).name = 'square limit set';
system(10).xvar = 'x';
system(10).yvar = 'y';
system(10).xder = ' (y + x/5)*(1-x^2)';
system(10).yder = ' -x*(1-y^2)';
system(10).pname = {'', '', '', '', '', ''};
system(10).pval = {'', '', '', ''};
system(10).fieldtype = 'arrows';
system(10).npts = npts;
system(10).wind = [-1.5 1.5 -1 1];
ud.c = system(1); % Changed values.
pname = ud.c.pname;
for kk = length(pname)+1:6
pname{kk} = '';
end
pval = ud.c.pval;
for kk = length(pval)+1:6
pval{kk} = '';
end
ud.c.pname = pname;
ud.c.pval = pval;
ud.o = ud.c; % Original values.
% ud.h = system(1); % This will be the handles in the
% setup window.
ud.style = style;
ud.npts = npts;
ud.settings.magn = 1.25;
ud.settings.refine = 8;
ud.settings.tol = tol;
ud.settings.solver = solver;
ud.settings.stepsize = stepsize;
ud.settings.speed = 100;
ud.system = system;
ud.solvers = {'ppdp45';
'rk4';
'ode45';
'ode23';
'ode113';
'ode15s';
'ode23s';
'ode23t';
'ode23tb'};
switch style % Note that an earlier line explicitly sets style = 'white' so none of this gets called
case 'black'
color.temp = [1 0 0]; % red for temporary orbits
color.orb = [1 1 0]; % yellow for orbits
color.eqpt = [1 0 0]; % red for eq. pts.
color.arrows = .5*[1 1 1]; % gray for arrows
color.narrows = .7*[1 1 1]; % gray for nullcline arrows
color.tx = [1 1 0]; % yellow for xt plots & 3D plots
color.ty = [1 0 0]; % red for yt plots
color.ta = [1 0 0]; % red for axis plots
color.sep = [.2,1,0]; % green for separatrices
color.xcline = [1 1 1]; % white for xclines
color.ycline = [1 0 1]; % magenta for yclines
color.level = [1,.5,.5];
case 'white'
color.temp = [1 0 0]; % red for temporary orbits
color.orb = [0 0 1]; % blue for orbits
color.eqpt = [1 0 0]; % red for eq. pts.
color.arrows = 0.7*[1 1 1]; % gray for arrows
color.narrows = .4*[1 1 1]; % gray for nullcline arrows
color.tx = [0 0 1]; % blue for xt plots & 3D plots
color.ty = [1 0 0]; % red for yt plots
color.ta = [1 0 0]; % red for axis plots
color.sep = [0,1,0];% green for separatrices
color.xcline = [1 0 .75]; % magenta for xclines
color.ycline = [1 .5 0]; % orange for yclines
color.level = 0.8*[.9,.5,.8];
case 'test'
color.temp = [1 0 0]; % red for temporary orbits
color.orb = [0 0 1]; % blue for orbits
color.arrows = .7*[1 1 1]; % gray for arrows
color.eqpt = [1 0 0]; % red for eq. pts.
color.narrows = .4*[1 1 1]; % gray for nullcline arrows
color.tx = [0 0 1]; % blue for xt plots & 3D plots
color.ty = [1 0 0]; % red for yt plots
color.ta = [1 0 0]; % red for axis plots
color.sep = [0,1,0];% green for separatrices
color.xcline = [1 0 .75]; % magenta for xclines
color.ycline = [1 .5 0]; % orange for yclines
color.level = [1,.5,.5];
case 'display'
color.temp = [1 0 0]; % red for temporary orbits
color.orb = [0 0 1]; % blue for orbits
color.arrows = .4*[1 1 1]; % gray for arrows
color.eqpt = [1 0 0]; % red for eq. pts.
color.narrows = .4*[1 1 1]; % gray for nullcline arrows
color.tx = [0 0 1]; % blue for xt plots & 3D plots
color.ty = [1 0 0]; % red for yt plots
color.ta = [1 0 0]; % red for axis plots
color.sep = 2*[.5 0 .5];% [0,1,0];% green for separatrices
color.xcline = [1 0 .75]; % magenta for xclines
color.ycline = [1 .5 0]; % orange for yclines
color.level = 0.8*[.9,.5,.8];
case 'bw'
color.temp = [1 1 1]; % white for everything
color.orb = [1 1 1];
color.eqpt = [1 1 1];
color.arrows = [1 1 1];
color.narrows = [1 1 1];
color.tx = [1 1 1];
color.ty = [1 1 1];
color.ta = [1 1 1];
color.sep = [1 1 1];
color.xcline = [1 1 1];
color.ycline = [1 1 1];
color.level = [1,1,1];
end
ud.color = color;
ud.level = ' ';
ppset = figure('name','matpplane Setup',...
'tag','matpplane','visible','off',...
'UserData',ud);
% ppset = figure('name','matpplane Setup','numb','off',...
% 'tag','matpplane','visible','off',...
% 'UserData',ud);
matpplane('figdefault',ppset);
frame(1) = uicontrol('style','frame','visible','off');
eq(1)=uicontrol('style','text',...
'horizon','center',...
'string','The differential equations.','visible','off');
ext = get(eq(1),'extent');
rr=ext(4)/10;
texth =ext(4)+4; % 19; % Height of text boxes.
varw = 40*rr; % Length of variable boxes.
equalw =13*rr; % Length of equals.(30)
eqlength = 230*rr; % Length of right hand sides of equations.
winstrlen = 120*rr; % Length of string boxes in display frame.
left = 0; % Left margin of the frames.
frsep = 1; %3; % Separation between frames.
separation = texth; % Separation between boxes.
dfigwidth =2*left + varw+equalw+eqlength+10; % Width of the figure.
dfigurebot = 30; % Bottom of the figure.
buttw = dfigwidth/3;
qwind = [0,frsep,buttw,separation]; % Quit button
rwind = [buttw,frsep,buttw,separation]; % Revert "
pwind = [2*buttw,frsep,buttw,separation]; % Proceed "
disfrbot = 2*frsep + separation; % Display frame.
disfrw = winstrlen + varw +10;
disfrht = 5*separation + 10;
disfrwind = [left, disfrbot, disfrw, disfrht];
pfrbot = disfrbot + disfrht +frsep; % Parameter frame.
pfrw = dfigwidth -2*left;
pfrht = 3*separation + 10;
pfrwind = [left, pfrbot, pfrw, pfrht];
defrbot = pfrbot + pfrht + frsep; % Equation frame.
defrw = pfrw;
defrht = 3*separation + 10;
defrwind = [left, defrbot, defrw, defrht];
ffrbot = disfrbot; % Field frame.
ffrleft = left + disfrw + frsep;
ffrw = dfigwidth -left - ffrleft;
ffrht = disfrht;
ffrwind = [ffrleft, ffrbot, ffrw, ffrht];
dfigureheight = defrbot + defrht +frsep; % Height of the figure.
set(ppset,'pos',[30 dfigurebot dfigwidth dfigureheight]);
set(frame(1),'pos',defrwind);
xname=[
'ud = get(gcf,''UserData'');'...
'Xname=get(ud.h.xvar,''string'');'...
'minxstr = [''The minimum value of '',Xname,'' = ''];',...
'set(ud.h.twind(1),''string'',minxstr);'...
'maxxstr = [''The maximum value of '',Xname,'' = ''];',...
'set(ud.h.twind(2),''string'',maxxstr);'...
'ud.c.xvar = Xname;'...
'ud.flag = 0;'...
'ud.c.name = '''';',...
'set(gcf,''UserData'',ud);'];
yname=[
'ud = get(gcf,''UserData'');'...
'Yname=get(ud.h.yvar,''string'');'...
'minystr = [''The minimum value of '',Yname,'' = ''];',...
'set(ud.h.twind(3),''string'',minystr);'...
'maxystr = [''The maximum value of '',Yname,'' = ''];',...
'set(ud.h.twind(4),''string'',maxystr);'...
'ud.c.yvar = Yname;'...
'ud.flag = 0;'...
'ud.c.name = '''';',...
'set(gcf,''UserData'',ud);'];
xder =[
'ud = get(gcf,''UserData'');'...
'ud.c.xder = get(ud.h.xder,''string'');'...
'ud.flag = 0;'...
'ud.c.name = '''';',...
'set(gcf,''UserData'',ud);'];
yder =[
'ud = get(gcf,''UserData'');'...
'ud.c.yder = get(ud.h.yder,''string'');'...
'ud.flag = 0;'...
'ud.c.name = '''';',...
'set(gcf,''UserData'',ud);'];
equationbot = defrbot + 5;
eqlabelbot = equationbot + 2*separation;
xbot = equationbot + separation; % Bottom of x equation.
ybot = equationbot; % Bottom of y equation.
lablen =200*rr;
eqlableft = (dfigwidth-lablen)/2;
eqleft = left + 5;
fudge = 0.15*separation;
set(eq(1),'pos',[eqlableft eqlabelbot lablen texth]);
tcolor = get(gcf,'defaultuicontrolbackgroundcolor');
ecolor = 'w';
ud.h.xvar=uicontrol('pos',[eqleft, xbot, varw, texth],...
'style','edit',...
'horizon','right',...
'string',ud.o.xvar,...
'CallBack',xname,...
'backgroundcolor',ecolor,...
'visible','off');
[~] = uicontrol('style','text',...
'pos',[eqleft+varw xbot equalw texth],...
'horizon','center',...
'string',''' = ',...
'backgroundcolor',tcolor,...
'visible','off');
ud.h.xder=uicontrol('pos',[eqleft+varw+equalw xbot eqlength texth],...
'string',ud.o.xder,...
'horizon','left','style','edit',...
'backgroundcolor',ecolor,...
'CallBack',xder,'visible','off');
ud.h.yvar=uicontrol('pos',[eqleft ybot varw texth],...
'style','edit',...
'horizon','right',...
'string',ud.o.yvar,...
'backgroundcolor',ecolor,...
'CallBack',yname,'visible','off');
[~] = uicontrol('style','text',...
'pos',[eqleft+varw ybot equalw texth],...
'horizon','center','string',''' = ',...
'backgroundcolor',tcolor',...
'visible','off');
ud.h.yder=uicontrol('pos',[eqleft+varw + equalw ybot eqlength texth],...
'string',ud.o.yder,...
'horizon','left','style','edit',...
'backgroundcolor',ecolor,...
'CallBack',yder,'visible','off');
[~] = uicontrol('style','frame','pos',disfrwind,'visible','off');
w1 = [
'ud = get(gcf,''UserData'');'...
'nnn = str2num(get(ud.h.wind(1),''string''));'...
'if isempty(nnn),',...
' set(ud.h.wind(1),''string'',''?'');',...
' nnn = NaN;',...
'end,',...
'ud.c.wind(1) = nnn;',...
'ud.c.name = '''';',...
'set(gcf,''UserData'',ud);'];
w2 = [
'ud = get(gcf,''UserData'');'...
'nnn = str2num(get(ud.h.wind(2),''string''));'...
'if isempty(nnn),',...
' set(ud.h.wind(2),''string'',''?'');',...
' nnn = NaN;',...
'end,',...
'ud.c.wind(2) = nnn;',...
'ud.c.name = '''';',...
'set(gcf,''UserData'',ud);'];
w3 = [
'ud = get(gcf,''UserData'');'...
'nnn = str2num(get(ud.h.wind(3),''string''));'...
'if isempty(nnn),',...
' set(ud.h.wind(3),''string'',''?'');',...
' nnn = NaN;',...
'end,',...
'ud.c.wind(3) = nnn;',...
'ud.c.name = '''';',...
'set(gcf,''UserData'',ud);'];
w4 = [
'ud = get(gcf,''UserData'');'...
'nnn = str2num(get(ud.h.wind(4),''string''));'...
'if isempty(nnn),',...
' set(ud.h.wind(4),''string'',''?'');',...
' nnn = NaN;',...
'end,',...
'ud.c.wind(4) = nnn;',...
'ud.c.name = '''';',...
'set(gcf,''UserData'',ud);'];
winbot1 = disfrbot + disfrht - 5 - separation;
winbot2 = winbot1 - separation;
winbot3 = winbot2 - separation;
winbot4 = winbot3 - separation;
winbot5 = winbot4 - separation;
[~] = uicontrol('style','text',...
'pos',[eqleft winbot1 disfrw-10 texth],...
'horizon','center',...
'string','The display window.','visible','off');
% ud.h.twind contains the handles to the text windows, and ud.h.wind
% contains the handles to the edit windows.
twstr1 = ['The minimum value of ',ud.o.xvar,' = '];
ud.h.twind(1) = uicontrol('style','text',...
'pos',[eqleft winbot2 winstrlen texth],...
'horizon','right',...
'string',twstr1,...
'backgroundcolor',tcolor',...
'visible','off');
ud.h.wind(1) = uicontrol('style','edit',...
'pos',[eqleft+winstrlen winbot2 40*rr texth],...
'string',num2str(ud.o.wind(1)),...
'backgroundcolor',ecolor,...
'CallBack',w1,'visible','off');
twstr2 = ['The maximum value of ',ud.o.xvar,' = '];
ud.h.twind(2) = uicontrol('style','text',...
'pos',[eqleft winbot3 winstrlen texth],...
'horizon','right',...
'string',twstr2,...
'backgroundcolor',tcolor',...
'visible','off');
ud.h.wind(2) = uicontrol('style','edit',...
'pos',[eqleft+winstrlen winbot3 40*rr texth],...
'string',num2str(ud.o.wind(2)),...
'backgroundcolor',ecolor,...
'CallBack',w2,'visible','off');
twstr3 = ['The minimum value of ',ud.o.yvar,' = '];
ud.h.twind(3)= uicontrol('style','text',...
'pos',[eqleft winbot4 winstrlen texth],...
'horizon','right',...
'string',twstr3,...
'backgroundcolor',tcolor',...
'visible','off');
ud.h.wind(3) = uicontrol('style','edit',...
'pos',[eqleft+winstrlen winbot4 40*rr texth],...
'string',num2str(ud.o.wind(3)),...
'backgroundcolor',ecolor,...
'CallBack',w3,'visible','off');
twstr4 = ['The maximum value of ',ud.o.yvar,' = '];
ud.h.twind(4) = uicontrol('style','text',...
'pos',[eqleft winbot5 winstrlen texth],...
'horizon','right',...
'string',twstr4,...
'backgroundcolor',tcolor',...
'visible','off');
ud.h.wind(4) = uicontrol('style','edit',...
'pos',[eqleft+winstrlen winbot5 40*rr texth],...
'string',num2str(ud.o.wind(4)),...
'backgroundcolor',ecolor,...
'CallBack',w4,'visible','off');
[~]=uicontrol('style','frame','pos',pfrwind,'visible','off');
pnCallBack = [
'[h,fig] = gcbo;'...
'ud = get(fig,''UserData'');'...
'num = get(h,''UserData'');'...
'ud.c.pname{num} = get(ud.h.pname(num),''string'');'...
'ud.flag = 0;'...
'set(gcf,''UserData'',ud);'];
pvCallBack = [
'[h,fig] = gcbo;'...
'ud = get(fig,''UserData'');'...
'num = get(h,''UserData'');'...
'ud.c.pval{num} = get(ud.h.pval(num),''string'');'...
'ud.flag = 0;'...
'set(gcf,''UserData'',ud);'];
pnamew = 40*rr;
%pvalw = 50*rr;
peqw = 10*rr;
pbot(3) = pfrbot + 5;
pbot(2) = pbot(3) + separation;
pbot(1) = pbot(2) + separation;
%pleft1 = eqleft + 50*rr + 5;
%peqleft1 = pleft1 + pnamew;
%pvleft1 = peqleft1 + peqw;
%pleft2 = dfigwidth - 10 - pnamew - pvalw - peqw;
%peqleft2 = pleft2 + pnamew;
%pvleft2 = peqleft2 + peqw;
paratit=uicontrol('style','text',...
'horizon','center',...
'string',{'Parameters';'or';'expressions'},...
'backgroundcolor',tcolor',...
'visible','off');
ext = get(paratit,'extent');
paratitw = ext(3);
pos = [eqleft pfrbot+2+texth/2 paratitw 2.1*texth];
set(paratit,'pos',pos);
psep = 20;
pvalw = (dfigwidth - 2*eqleft - paratitw)/2 - psep - pnamew - peqw;
pval = ud.c.pval;
pname = ud.c.pname;
for jj = 1:3
for kk = 1:2
pleft = eqleft + paratitw +psep +(kk-1)*(pnamew+peqw+pvalw+ psep);
peqleft = pleft + pnamew;
pvleft = peqleft + peqw;
K = kk +2*(jj-1);
name = pname{K};
value = pval{K};
ud.h.pname(K) = uicontrol('style','edit',...
'pos',[pleft pbot(jj) pnamew texth],...
'horizon','right','string',name,...
'UserData',K,...
'CallBack',pnCallBack,...
'visible','off',...
'backgroundcolor','w');
[~] = uicontrol('style','text',...
'pos',[peqleft pbot(jj)-fudge peqw texth],...
'horizon','center',...
'string','=',...
'visible','off');
ud.h.pval(K) = uicontrol('style','edit',...
'pos',[pvleft pbot(jj) pvalw texth],...
'string',value,...
'CallBack',pvCallBack,...
'visible','off',...
'UserData',K,...
'backgroundcolor','w');
end
end
ud.c.pname = pname;
ud.c.pval = pval;
[~] = uicontrol('style','push',...
'pos',qwind,...
'string','Quit','CallBack',...
'matpplane(''quit'')',...
'visible','off');
[~] = uicontrol('style','push',...
'pos',rwind,...
'string','Revert',...
'CallBack','matpplane(''revert'')',...
'visible','off');
[~] = uicontrol('style','push',...
'pos',pwind,...
'string','Proceed',...
'CallBack','matpplane(''proceed'')',...
'visible','off');
[~] = uicontrol('style','frame','pos',ffrwind,'visible','off');
[~] = uicontrol('style','text',...
'pos',[ffrleft+5,winbot1,ffrw-10,texth],...
'string','The direction field.',...
'horizon','center','visible','off');
radleft = ffrleft + 3;
radw = 50*rr;
typewindw = radw +6;
typewind = [ffrleft, ffrbot, typewindw, ffrht-separation-3];
textwindl = ffrleft+typewindw;
textleft = textwindl + 3;
textw = ffrw - typewindw;
textwind = [textwindl, ffrbot,textw, ffrht-separation-3];
[~] = uicontrol('style','frame','pos',typewind,'visible','off');
[~] = uicontrol('style','frame','pos',textwind,'visible','off');
switch ud.o.fieldtype
case 'nullclines'
rval1 = 1;rval2 = 0;rval3 = 0;rval4 = 0;
case 'lines'
rval1 = 0;rval2 = 2;rval3 = 0;rval4 = 0;
case 'arrows'
rval1 = 0;rval2 = 0;rval3 = 3;rval4 = 0;
case 'none'
rval1 = 0;rval2 = 0;rval3 = 0;rval4 = 4;
otherwise
error('PPLANE:UnknownFieldType1',['Unknown fieldtype ',ud.o.fieldtype,'.'])
end
ud.h.rad(1) = uicontrol('style','radio',...
'pos',[radleft winbot4 radw texth],...
'string','Nullclines',...
'value',rval1,...
'visible','off');
ud.h.rad(2) = uicontrol('style','radio',...
'pos',[radleft winbot3 radw texth],...
'string','Lines',...
'value',rval2,...
'max',2,...
'visible','off');
ud.h.rad(3) = uicontrol('style','radio',...
'pos',[radleft winbot2 radw texth],...
'string','Arrows',...
'value',rval3,...
'max',3,...
'visible','off');
ud.h.rad(4) = uicontrol('style','radio',...
'pos',[radleft winbot5 radw texth],...
'string','None',...
'value',rval4,...
'max',4,...
'visible','off');
for i=1:4
set(ud.h.rad(i),'UserData',ud.h.rad(:,[1:(i-1),(i+1):4]));
end
CallBackrad = [
'me = get(gcf,''currentobject'');',...
'kk = get(me,''max'');',...
'set(get(me,''UserData''),''value'',0),',...
'set(me,''value'',kk);',...
'ud = get(gcf,''UserData'');',...
'switch kk,',...
' case 1, ud.c.fieldtype = ''nullclines'';',...
' case 2, ud.c.fieldtype = ''lines'';',...
' case 3, ud.c.fieldtype = ''arrows'';',...
' case 4, ud.c.fieldtype = ''none'';',...
'end,',...
'set(gcf,''UserData'',ud);'];
set(ud.h.rad,'CallBack',CallBackrad);
nfptsstr = {'Number of'; 'field points per'; 'row or column.'};
[~] = uicontrol('style','text',...
'pos',[textleft winbot4 textw-5 2.5*texth],...
'string',nfptsstr,...
'horizon','center',...
'visible','off');
CallBacknfpts = [
'ppset = findobj(''name'',''matpplane Setup'');',...
'ud = get(ppset,''UserData'');'...
'me = ud.h.npts;',...
'kk = str2num(get(me,''string''));',...
'if isempty(kk),',...
' set(me,''string'',''?'');',...
' kk = NaN;',...
'else,',...
' kk = floor(kk);',...
' [m,N] = computer;'...
' if (N <= 8192),',...
' N = 32;',...
' else,',...
' N = 50;',...
' end,'...
' kk = min([N,max([5,kk])]);'...
' set(me,''string'',num2str(kk));'...
'end,'...
'ud.c.npts = kk;',...
'set(ppset,''UserData'',ud);'];
npos = [textleft+(textw -30*rr)/2,winbot5 30*rr,texth];
ud.h.npts = uicontrol('style','edit',...
'pos',npos,...
'string',ud.o.npts,...
'CallBack',CallBacknfpts,...
'backgroundcolor','w',...
'visible','off');
delgall = ['sud = get(gcf,''UserData'');',...
'mh = get(sud.h.gallery,''children'');',...
'add = findobj(sud.h.gallery,''tag'',''add system'');',...
'mh(find(mh == add)) = [];',...
'delete(mh);',...
'set(sud.h.gallery,''UserData'',[]);',...
'set(findobj(''tag'',''load default''),''enable'',''on'')'];
% Menus
hhsetup = get(0,'showhiddenhandles');
set(0,'showhiddenhandles','on');
mefile = findobj(ppset,'label','&File');
meedit = findobj(ppset,'label','&Edit');
delete(findobj(ppset,'label','&Tools'));
delete(findobj(ppset,'label','&View'));
delete(findobj(ppset,'label','&Insert'));
% File menu
meexp = findobj(mefile,'label','&Export...');
meprev = findobj(mefile,'label','Print Pre&view...');
mepset = findobj(mefile,'label','Pa&ge Setup...');
set(get(mefile,'child'),'vis','off');
[~] = uimenu(mefile,'label','Load a system ...',...
'CallBack','matpplane(''loadsyst'',''system'');',...
'pos',1);
[~] = uimenu(mefile,'label','Save the current system ...',...
'CallBack','matpplane(''savesyst'',''system'');',...
'pos',2);
[~] = uimenu(mefile,'label','Load a gallery ...',...
'CallBack','matpplane(''loadsyst'',''gallery'');',...
'separator','on','pos',3);
[~] = uimenu(mefile,'label','Save a gallery ...',...
'CallBack','matpplane(''savesyst'',''gallery'');',...
'tag','savegal','pos',4);
[~] = uimenu(mefile,'label','Delete the current gallery',...
'CallBack',delgall,'pos',5);
[~] = uimenu(mefile,'label','Load the default gallery',...
'CallBack','matpplane(''loadsyst'',''default'');',...
'enable','on',...
'tag','load default','pos',6);
[~] = uimenu(mefile,'label','Revert','CallBack',...
'matpplane(''revert'')',...
'separator','on','pos',7);
[~] = uimenu(mefile,...
'label','Proceed',...
'CallBack','matpplane(''proceed'')',...
'separator','off',...
'accelerator','G','pos',8);
set(mepset,'vis','on','pos',9);
set(meprev,'vis','on','pos',10);
set(meexp,'vis','on','pos',11,'separator','off');
[~] = uimenu(mefile,'label',...
'Restart matpplane',...
'CallBack','matpplane(''restart'')',...
'separator','on','pos',12);
[~] = uimenu(mefile,...
'label','Quit matpplane',...
'CallBack','matpplane(''quit'')',...
'separator','off','pos',13);
% Edit menu
set(get(meedit,'child'),'vis','off');
[~] = uimenu(meedit,'label','Clear equations',...
'CallBack',['ud = get(gcf,''UserData'');h = ud.h;',...
'set([h.xvar,h.xder,h.yvar,h.yder],''string'','''');'],...
'accelerator','E');
pclear = [
'ud = get(gcf,''UserData'');h = ud.h;',...
'set([h.pname,h.pval],''string'','''');',...
'ud.c.pname = {'''','''','''','''','''','''',''''};',...
'ud.c.pval = {'''','''','''','''','''','''',''''};',...
'set(gcf,''UserData'',ud);',...
];
[~] = uimenu(meedit,'label','Clear parameters',...
'CallBack',pclear,...
'accelerator','N');
[~] = uimenu(meedit,'label','Clear display window',...
'CallBack',['ud = get(gcf,''UserData'');',...
'set(ud.h.wind,''string'','''');'],...
'accelerator','D');
allclear = [
'ud = get(gcf,''UserData'');h = ud.h;',...
'set([h.xvar,h.xder,h.yvar,h.yder],''string'','''');',...
'set([h.pname,h.pval,h.wind],''string'','''');',...
'ud.c.pname = {'''','''','''','''','''','''',''''};',...
'ud.c.pval = {'''','''','''','''','''','''',''''};',...
'set(gcf,''UserData'',ud);',...
];
[~] = uimenu(meedit,'label','Clear all',...
'CallBack',allclear,...
'accelerator','A',...
'separator','on');