このコードは単にt
の種類、ならびに現在format
設定に応じて可変t
の値を表示する方法を決定します。
% If this is a PhArea instance
if isa(t, 'PhArea)
% Then just display it
disp(t)
% If the user has enabled compact formatting (format compact)
elseif isequal(get(0, 'formatspacing'), 'compact')
% Display the variable's name and an equal sign (no spaces)
disp([inputname(1), '='])
% Display the variable itself
disp(t)
% Otherwise
else
% Display an empty line
disp(' ')
% Display the variable's name and an equal sign (with space)
disp([inputname(1), ' ='])
% Display an empty line
disp(' ')
% Display the variable
disp(t)
end
更新
次の行は、ここにトリッキーです。
isequal(get(0, 'formatspacing'), 'compact')
これは現在のformat spacingを取得します。 0
は、グラフィックroot objectであり、特定のMATLABセッションに適用される情報を格納するために使用されます。ユーザーが'compact'
形式のスペースを使用するように指定すると、この構成はルートオブジェクト内に格納されます。
format loose
get(0, 'formatspacing')
% loose
format compact
get(0, 'formatspacing')
% compact
だから文字列として現在の設定を取得することによって、あなたは、ユーザーが間隔やないコンパクトな形式を使用したいかどうかを確認するために'compact'
に(isequal
を使用して)それを比較することができます。
あなたの質問にコードを投稿し、スクリーンショットを添付しないでください。 – Suever
@Suever完了しました – chsafouane
コードを実行するのが最も良い方法です。デバッガを見てください。http://se.mathworks.com/help/matlab/debugging-code.html – patrik