⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plothistory.m

📁 approximate reinforcement learning
💻 M
字号:
function figh = plothistory(hist)% Utility function to plot controlled trajectory of a system%   FIGH = PLOTHISTORY(HIST)% Parameters:%   HIST    - the history as generated by fuzzyqi, tilingqi, etc.% Returns:%   FIGH    - a handle to the created figure% number of states and inputsp = size(hist.x, 1);q = size(hist.u, 1);Ns = size(hist.x, 2);       % number of samples% if fewer than 40 samples, plot in stairs, otherwise in continuous linesif Ns <= 40, plotfun = @stairs;else plotfun = @plot;end;% note commands are always plotted in stairsfigsize = [500 800]; styles = {{'k-','LineWidth',1}, {'k-','LineWidth',2,'Color',[.6,.6,.6]}, ...    {'k:','LineWidth',1}, {'k--','LineWidth',1}};      % b/w stylesfigh = figure('Name', 'Controlled system evolution', 'NumberTitle','off', 'Position', [0 0 figsize]);movegui(figh, 'center');% statessubplot(311); hold on; leg = {};for i = 1:p    feval(plotfun, hist.t, hist.x(i, :), styles{i}{:});     leg{end+1} = ['x_' num2str(i) '(t)'];end;grid on;if p > 1,   legend(leg); ylabel('States');else        ylabel('State x(t)');end;subplot(312); hold on; leg = {};for i = 1:q    stairs(hist.t, hist.u(i, :), styles{i}{:});     leg{end+1} = ['u_' num2str(i) '(t)'];end;grid on; if q > 1,   legend(leg); ylabel('Controls');else        ylabel('Control u(t)');end;% rewardsubplot(313); hold on; feval(plotfun, hist.t, hist.r, styles{1}{:});grid on; ylabel('Reward');xlabel('t [sec]');          % last plot, put an x label

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -