dfield8 with R2015b on Mac OSX issues?
Show older comments
Is there a better option for first order ODE solving/plotting in Matlab than dfield8? It gives me problems every time I attempt to enter differential equations. My latest issue is as follows:
Reference to non-existent field 'axes'.
Error in dfield8 (line 813)
aud = get(dud.axes,'UserData');
Error while evaluating UIControl Callback
Any help or better options would be much appreciated.
5 Comments
Walter Roberson
on 10 Sep 2015
John Wolfe
on 11 Sep 2015
Edited: Walter Roberson
on 11 Sep 2015
Roy, I'm having the same problem. Our DiffEq prof wants us to use dfield8, but it is only compatible up to MATlab 7.7 (R2008b). It seems as though someone must have updated the code in the last 7 years since that was new... and Walter, yes, from the rice website. Do you know of any updated versions?
My errors with the 'newest' version of dfield8 is as follows:
"Error using figure
There is no numb property on the Figure class.
Error in dfield8 (line 258)
dfset = figure('name','dfield8 Setup','numb','off',..."
I found this code, which works but has no GUI or interactive display, you need to enter the equations, limits, and solution curves when calling the .m file:
function dirfield(f,tval,yval)
% dirfield(f, t1:dt:t2, y1:dy:y2)
%
% plot direction field for first order ODE y' = f(t,y)
% using t-values from t1 to t2 with spacing of dt
% using y-values from y1 to t2 with spacing of dy
%
% f is an @ function, or an inline function,
% or the name of an m-file with quotes.
%
% Example: y' = -y^2 + t
% Show direction field for t in [-1,3], y in [-2,2], use
% spacing of .2 for both t and y:
%
% f = @(x,y) y*x
% dirfield(f, -10:.2:10, -10:.2:10)
% hold
% [ts,ys] = ode45(f,[x0,xf],y0)
% plot(ts,ys,'k-')
[tm,ym]=meshgrid(tval,yval);
dt = tval(2) - tval(1);
dy = yval(2) - yval(1);
fv = vectorize(f);
if isa(f,'function_handle')
fv = eval(fv);
end
yp=feval(fv,tm,ym);
s = 1./max(1/dt,abs(yp)./dy)*0.35;
h = ishold;
quiver(tval,yval,s,s.*yp,0,'.r'); hold on;
quiver(tval,yval,-s,-s.*yp,0,'.r');
if h
hold on
else
hold off
end
axis([tval(1)-dt/2,tval(end)+dt/2,yval(1)-dy/2,yval(end)+dy/2])
Walter Roberson
on 11 Sep 2015
For R2014b and later, change
dfset = figure('name','dfield8 Setup','numb','off',..."
to
dfset = figure('name','dfield8 Setup','numbertitle','off',..."
Arthur Wasserman
on 3 Mar 2016
It would be a great service if someone were to update dfield, pplane, and odesolve for the latest version of Matlab.
Walter Roberson
on 12 Mar 2016
It would be a great service, yes -- but performing the service doesn't pay any bills.
Answers (3)
Rick Saltzman
on 13 Feb 2016
Errors also arise due to the use of:
if notice
and
if dud.notice
These are corrected by:
if ~isEmpty(notice)
if ~isEmpty(dud.notice)
1 Comment
Nenad Dragojevic
on 15 Dec 2016
Edited: Nenad Dragojevic
on 15 Dec 2016
Hello, very nice answer, but in Matlab R2015a (Windows7): Undefined function '~isEmpty'!
'~isempty' works for me.
George Williams
on 17 Feb 2017
1 vote
Gives a good updated version for Matlab R2016b: https://uk.mathworks.com/matlabcentral/fileexchange/61636-pplane?s_tid=srchtitle%2520
you will find the both editions in this link (one for Matlab 2014 and before, the other is for Matlab 2015 and later):
Update: the file of pplane8.m which found in this link works for Matlab 2015 and later :)
2 Comments
sean orourke
on 13 Feb 2017
pplane8.m DOES NOT WORK for R2015b
Walter Roberson
on 14 Feb 2017
go through and replace every occurrence of 'numb' (the quoted string exactly like that) with 'numbertitle'. . Also replace one 'number' (the quotes string exactly like that) with 'numbertitle'
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!