Rewriting pplane and dfield

This is not quite a question in the usual MATLAB Answers sense, but I am hoping that someone who looks at MATLAB Answers might be able to help. I apologize in advance for the length of this submission. Other people have written to MATLAB Answers with similar questions, but none have really arrived at a satisfactory conclusions.
There is a pair of free third-party MATLAB programs for drawing direction fields and phase planes, written many years ago by John Polking and available here:
These were last updated 15 years or so ago and have not worked on any recent releases of MATLAB.
This is a real shame, as these programs are very useful for helping students to understand these important tools for analyzing ODE. Many college and university math departments use MATLAB throughout their curriculum, and these programs were a good tool for a sophomore-level math class. I used to assign them to my own classes.
There have been a number of attempts to re-create the functionality of these programs, including a Java version, an iOS replacement, a Python replacement, and a partial rewrite of the code in MATLAB. None of them work as well as pplane and dfield. So now, instead of being able to simply assign one MATLAB program, I maintain a webpage weighing the pros and cons of each replacement and telling the students to pick one: https://web.njit.edu/~goodman/courses/math222/matlabinformation/
I have found on File Exchange a number of attempts to revive this program. None of them work 100% on my Mac installation of MATLAB R2020b.
I really would like to be able to get these programs running again, but have no idea where to begin. The codes are a mess, each about 7000 lines and not even separated into functions! Plus I have no experience with GUI programming.
I think that having such a program would be very good for Mathworks, as many students first encounter MATLAB in lower-division undergraduate classes, and I often hear them complaining about the experience. Making this experience smooth might convince them that MATLAB is worth using in the future.
So, my queston: Can anybody inside or outside Mathworks help me get these programs running again at full capacity? Ideally I would like to modernize them, modularize the code, make it maintainable, and take advantage of 15 years worth of advances in MATLAB, especially the improved graphics.

12 Comments

Thanks, but I should add some more detail.
In these threads there is a post by Hugh Harvey which he says he implemented all the chages and put his edited version on file exchange here:
He says this should work on 2018b.
This runs for me on 2020b to a point. I can enter an ODE and click proceed. When I then click on the phase plane to draw a trajectory, nothing happens and I get the following error message:
Error using feval
Unrecognized function or variable 'pptp5582'.
Error in pplane8 (line 3183)
Ww = feval(dfcn,0,[Xx';Yy']);
Error in pplane8 (line 2745)
pplane8('dirfield',ppdisp);
Error while evaluating UIControl Callback.
There is another recent submission by Mason Nixon that also gives errors in 2020b.
I've gotten some help from readers of the SIAM dynamicall systems listserv, and understand your advice a little bit better than I did before. I'm going through the GUI and pushing all the buttons looking for bugs.
I have hit another callback that seems to have been changed in some MATLAB update:
Error using matlab.graphics.axis.Axes/set
Unrecognized property inter for class Axes.
Error in matpplane (line 5851)
set(gca,'inter','on');
Error while evaluating Menu Callback.
Interruptible
It used to be unique up to 'inter' but another property 'interactions' was added (which I had never noticed before) so there is now a conflict with abbreviating to 'inter'
Is there a document anywhere outlining the changes in the handle graphics over the years and how to bring codes up to date?
No. The number of new handle graphics properties is huge, with many of the internal ones not well documented (or not documented at all.)
Look for calls to set(), and figure out what kind of object is being worked with. Look up the object properties in the R2014a documentation, and in any case where an abbreviation has been used, fill it out with the full name of the R2014a property.
The only property I can think of at the moment that got a conflicting name as of HG2 is Number vs NumberTitle for figures.
But... if you see calls to set() properties of legend(), or of contour plots, or of colorbar(), then you might need to rewrite the code. It was common to configure properties of all of those based upon the old implementation, but the current implementation is quite different for those, and finding equivalents can be tricky (especially for changing details of exactly how legend entries appear.)
Also, in those days it was still common to use a trailing number in a call to legend() to designate a position for the legend to appear; those got replaced with named locations such as 'east'.
Next error message:
Error using matlab.graphics.axis.Axes/get
Unrecognized property zdata for class Axes.
Error in matpplane (line 6404)
tval = get(th,'zdata');
Thanks.
MATLAB is case-sensitive, and 'XData', 'YData', and 'ZData' are properties of the line (or surface) object, not the Axes. If ‘th’ were the handle to the line or surface object, ‘tval’ would likely return numeric values (vector or matrix).
When you get() then nothing is case sensitive. When you access using struct field notation then that is case sensitive.
Hmm. Of course there are 10 different places where 'th' may have been set. Time for a whole lot of conditional breakpoints.
Still working on this code. It contains many calls like this
dwindow = uicontrol('style','text',...
'pos',[eqleft winbot1 disfrw-10 texth],...
'horizon','center',...
'string','The display window.','visible','off');
These assign the result of a uicontrol command to a variable. These variables are almost never called again, so the Code Analyzer reports gives me value assigned may be unused warnings. Is it safe to call uicontrol without assigning the result to a variable?
Yes, it is safe to call uicontrol without assigning the result to a variable.
For R2009b and later (I think it was, maybe R2009a) you can also use [~] as the output if you are worried about side effects not happening. This can make a difference for legend() calls: legend() with zero or one outputs uses different internal representation than legend with two or more outputs.
a = uicontrol('style', 'text', 'string', 'hello')
a =
UIControl (hello) with properties: Style: 'text' String: 'hello' BackgroundColor: [0.9400 0.9400 0.9400] Callback: '' Value: 0 Position: [20 20 60 20] Units: 'pixels' Show all properties
[~] = uicontrol('style', 'text', 'string', 'stranger')

Sign in to comment.

 Accepted Answer

Jiro Doke
Jiro Doke on 21 May 2021
You may want to try the newly "recreated" Phase Plane and Slope Field Apps.
It says it requires R2021a or later.

2 Comments

Thanks, Jiro. I know it! I've actually been beta-testing the new programs for Brian.
Excellent! Thanks for beta testing!

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Products

Asked:

on 30 Dec 2020

Commented:

on 22 May 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!