ボード線図の線を任意の色にする /How to make the lines of a bode diagram any color specified by RGB

14 visualizaciones (últimos 30 días)
bodeを使用する際、rgbmrckでいろを指定することは可能ですが、16進数やRGBで指定する任意の色にも変更可能ですか?
How to make the lines of a 'bode' any color specified by RGB

Respuesta aceptada

Akira Agata
Akira Agata el 4 de Jul. de 2023
bode 関数で生成されるボード線図は Line オブジェクトで構成されています。
このため、findobj 関数で Line オブジェクトを抽出してプロパティをセットすることで対応可能です。
具体的には以下のようになります。
% サンプルのボード線図を作成
H = tf([1 0.1 7.5],[1 0.12 9 0 0]);
bode(H)
% Lineオブジェクトを抽出
h = findobj(gcf, 'Type','Line');
% 線の色を16進数で指定
set(h, 'Color', '#FF00FF');
  5 comentarios
Akira Agata
Akira Agata el 5 de Jul. de 2023
Editada: Akira Agata el 5 de Jul. de 2023
はい、複数の伝達関数に応用することも可能です。
ただ、これまでの方法では、伝達関数が増えるほど findobj で抽出される Line オブジェクトの数が増えるため、どれがどの伝達関数のものか分かりにくくなります (伝達関数 2個程度であれば問題ありませんが)。
どの伝達関数のものかを識別するには、たとえばまず最初にラインの色を 'r' や 'b' のような分かりやすい色に指定してボード線図を描いておいて、その後 findobj で「赤色の Line」「青色の Line」をそれぞれ抽出するのが良いかと思います。以下はその一例です。
% サンプルのボード線図を作成
H1 = tf([1 0.1 7.5], [1 0.12 9 0 0]);
H2 = tf([1 0.2 6.5], [1 0.12 9 0 0]);
bode(H1, 'r-', H2, 'b-')
% それぞれの色の Line オブジェクトを抽出
hl1 = findobj(gcf, 'Type', 'Line', 'Color', 'r');
hl2 = findobj(gcf, 'Type', 'Line', 'Color', 'b');
% 線の色を16進数やRGBで指定
set(hl1, 'Color', '#FF00FF');
set(hl2, 'Color', [0.5, 0.8, 0]);
% 凡例を表示
legend([hl1(1), hl2(1)], {'位相線図 1', '位相線図 2'});
legend([hl1(2), hl2(2)], {'ゲイン線図 1', 'ゲイン線図 2'});
ayumi obitsu
ayumi obitsu el 5 de Jul. de 2023
ありがとうございます。
理想のボード線図を描けました。

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre プロットのカスタマイズ en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!