ObjTrack.mという関数スクリプト内でプロットが行われているようですので、計算結果を関数から出力させればよいです。
以下のように改造しました。
% Copyright 2010 The MathWorks, Inc.
function [y_out, z_out] = ObjTrack(position)
%#codegen
% First, setup the figure
numPts = 300; % Process and plot 300 samples
figure;hold;grid; % Prepare plot window
y_out = zeros(2, numPts);
z_out = zeros(2, numPts);
% Main loop
for idx = 1: numPts
z = position(:,idx); % Get the input data
y = kalmanfilter(z); % Call Kalman filter to estimate the position
plot_trajectory(z,y); % Plot the results
y_out(:, idx) = y;
z_out(:, idx) = z;
end
hold;
end % of the function
その後、CCodeGenerationForAMATLABKalmanFilteringAlgorithmExample.mlxの13行目を
[y, z] = ObjTrack(position)
とすることでベースワークスペースに数値データを記録することができます。
