Comments (7)
Line in BrysonHo156_plot:
Line in BrysonHo156:
from dt-qp-project.
@IanGowen I am not seeing this error when running BrysonHo156 using the most recent commit. Can you upload your version of BrysonHo156 here?
from dt-qp-project.
Yes
%--------------------------------------------------------------------------
% BrysonHo156.m
% p. 156 of A. E. Bryson Jr. and Y.-C. Ho, Applied Optimal Control.
% Taylor & Francis, 1975, isbn: 9780891162285
%--------------------------------------------------------------------------
%
%--------------------------------------------------------------------------
% Primary contributor: Daniel R. Herber (danielrherber on GitHub)
% Link: https://github.com/danielrherber/dt-qp-project
%--------------------------------------------------------------------------
function varargout = BrysonHo156(varargin)
% input arguments can be provided in the format 'BrysonHo156(auxdata,opts)'
% set local functions
ex_opts = @BrysonHo156_opts; % options function
ex_output = @BrysonHo156_output; % output function
ex_plot = @BrysonHo156_plot; % plot function
% set auxdata and opts (see local_opts)
[auxdata,opts] = DTQP_standardizedinputs(ex_opts,varargin);
%% tunable parameters
t0 = 0; tf = 10; % time horizon
auxdata.x0 = 10; auxdata.v0 = 1; auxdata.c = 1;
auxdata.omega = 1;
%% setup
% system dynamics
A = [0,1;-auxdata.omega^2,0];
B = [0;1];
% Lagrange term
L(1).left = 1; % control variables
L(1).right = 1; % control variables
L(1).matrix = 1/2; % 1/2*u^2
% Mayer term
M(1).left = 5; % final state variables
M(1).right = 5; % final state variables
M(1).matrix = [auxdata.c/2,0;0,0];
% initial conditions
LB(1).right = 4; % initial states
LB(1).matrix = [auxdata.x0;auxdata.v0];
UB(1).right = 4; % initial states
UB(1).matrix = [auxdata.x0;auxdata.v0];
% combine
setup.A = A; setup.B = B; setup.L = L; setup.M = M;
setup.LB = LB; setup.UB = UB; setup.t0 = t0; setup.tf = tf; setup.auxdata = auxdata;
%% solve
[T,U,Y,P,F,in,opts] = DTQP_solve(setup,opts);
%% output
[O,sol] = ex_output(T,U,Y,P,F,in,opts);
if nargout == 1
varargout{1} = O;
end
%% plot
ex_plot(T,U,Y,P,F,in,opts,sol)
end
% User options function for this example
function opts = BrysonHo156_opts
% test number
num = 2;
switch num
case 1
% default parameters
opts = [];
case 2
opts.dt.defects = 'HS';
opts.dt.quadrature = 'CQHS';
opts.dt.mesh = 'ED';
opts.dt.nt = 5;
opts.solver.tolerance = 1e-15;
opts.solver.maxiters = 200;
opts.solver.display = 'none';
opts.dt.meshr.method = 'SS-BETTS';
opts.dt.meshr.tolerance = 1e-8;
end
end
from dt-qp-project.
Heres the code for the plot:
%--------------------------------------------------------------------------
% BrysonHo156_plot.m
% Plot function for BrysonHo156 example
%--------------------------------------------------------------------------
%
%--------------------------------------------------------------------------
% Primary contributor: Daniel R. Herber (danielrherber on GitHub)
% Link: https://github.com/danielrherber/dt-qp-project
%--------------------------------------------------------------------------
function BrysonHo156_plot(in,opts)
if opts.general.plotflag
% preliminary plot options
flag = 'preliminary'; DTQP_plotCommon %#ok<NASGU>
%% state
figure('Color',wcolor); hold on
% plot state
solutionflag = true; %#ok<NASGU>
flag = 'plot-state'; DTQP_plotCommon %#ok<NASGU>
% configure axis
flag = 'axis'; DTQP_plotCommon %#ok<NASGU>
% save
figname = 'figure-state'; pathplots = msavename(mfilename('fullpath'),'plots'); %#ok<NASGU>
flag = 'save'; DTQP_plotCommon %#ok<NASGU>
%% control
figure('Color',wcolor); hold on
% plot control
solutionflag = true; %#ok<NASGU>
flag = 'plot-control'; DTQP_plotCommon %#ok<NASGU>
% configure axis
flag = 'axis'; DTQP_plotCommon %#ok<NASGU>
% save
figname = 'figure-control'; pathplots = msavename(mfilename('fullpath'),'plots'); %#ok<NASGU>
flag = 'save'; DTQP_plotCommon %#ok<NASGU>
%% error
figure('Color',wcolor); hold on
% plot error
flag = 'plot-error'; DTQP_plotCommon %#ok<NASGU>
% configure axis
flag = 'axis'; DTQP_plotCommon %#ok<NASGU>
% save
figname = 'figure-error'; pathplots = msavename(mfilename('fullpath'),'plots'); %#ok<NASGU>
flag = 'save'; DTQP_plotCommon %#ok<NASGU>
%% mesh refinement
if isfield(in,'meshr')
% step size plot
DTQP_MESH_plotStepsize(in.meshr.T)
% mesh error plot
DTQP_MESH_plotError(in.meshr.T,in.meshr.errors,in.meshr.tol)
end
end
from dt-qp-project.
Perhaps your BrysonHo156_plot function was modified from the current one on GitHub:
Note that the provided function has only 2 arguments rather than the full set T,U,Y,P,F,in,opts,sol
shown above.
from dt-qp-project.
Ok I modified the code, but Im still getting the same error. Here's the updated plot code:
`%--------------------------------------------------------------------------
% BrysonHo156_plot.m
% Plot function for BrysonHo156 example
%--------------------------------------------------------------------------
%
%--------------------------------------------------------------------------
% Primary contributor: Daniel R. Herber (danielrherber on GitHub)
% Link: https://github.com/danielrherber/dt-qp-project
%--------------------------------------------------------------------------
function BrysonHo156_plot(T,U,Y,P,F,in,opts)
if opts.general.plotflag
% preliminary plot options
flag = 'preliminary'; DTQP_plotCommon %#ok
%% state
figure('Color',wcolor); hold on
% plot state
solutionflag = true; %#ok
flag = 'plot-state'; DTQP_plotCommon %#ok
% configure axis
flag = 'axis'; DTQP_plotCommon %#ok
% save
figname = 'figure-state'; pathplots = msavename(mfilename('fullpath'),'plots'); %#ok
flag = 'save'; DTQP_plotCommon %#ok
%% control
figure('Color',wcolor); hold on
% plot control
solutionflag = true; %#ok
flag = 'plot-control'; DTQP_plotCommon %#ok
% configure axis
flag = 'axis'; DTQP_plotCommon %#ok
% save
figname = 'figure-control'; pathplots = msavename(mfilename('fullpath'),'plots'); %#ok
flag = 'save'; DTQP_plotCommon %#ok
%% error
figure('Color',wcolor); hold on
% plot error
flag = 'plot-error'; DTQP_plotCommon %#ok
% configure axis
flag = 'axis'; DTQP_plotCommon %#ok
% save
figname = 'figure-error'; pathplots = msavename(mfilename('fullpath'),'plots'); %#ok
flag = 'save'; DTQP_plotCommon %#ok
%% mesh refinement
if isfield(in,'meshr')
% step size plot
DTQP_MESH_plotStepsize(in.meshr.T)
% mesh error plot
DTQP_MESH_plotError(in.meshr.T,in.meshr.errors,in.meshr.tol)
end
end`
from dt-qp-project.
Adding "sol" in BrysonHo_156 fixed the issue.
from dt-qp-project.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dt-qp-project.