実行結果取得方法について
9 views (last 30 days)
Show older comments
こんにちは
カルマンフィルタの勉強をするためにMATLABを用いようとしています。
以下のURLのサイトにあるMATLABにおけるカルマンフィルタのサンプルを実行してみました。
グラフの作成は行えますが、プロットされた複数の出力データを取得方法がわかりません。
方法がわかる方、レクチャーしてくだされば助かります。
もしくは、グラフからデータを取得する方法もわかればありがたいです。
よろしくお願いいたします。
0 Comments
Answers (2)
Toshinobu Shintai
on 29 Jan 2020
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)
とすることでベースワークスペースに数値データを記録することができます。
0 Comments
See Also
Categories
Find more on 状態の推定 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!