凡例の系列名に変数の値を入れたいです
57 views (last 30 days)
Show older comments
凡例に変数のなかの値をいれたいです。方法があれば教えて欲しいです。
open_system( 'MPC_SISO_0_block' )
mpc_out = sim( 'MPC_SISO_0_block' );
figure
title( 'Deterioration of the MPC' )
hold on
plot( mpc_out.ScopeData{1}.Values.Time,mpc_out.ScopeData{2}.Values.Data,'LineWidth',2 )
dm = 0.1;
for cnt = -3:3
dp = dm * cnt;
d_K0 = K0 * dp;
num_p = K0 + d_K0;
plant = tf( num_p, den_p );
open_system( 'MPC_SISO_0_block' )
mpc_out = sim( 'MPC_SISO_0_block' );
plot( mpc_out.ScopeData{1}.Values.Time,mpc_out.ScopeData{2}.Values.Data )
% plot( mpc_out.ScopeData{1}.Values.Time,mpc_out.ScopeData{2}.Values.Data*(1+cnt*0.1) )
end
legend
title( 'MPC K' )
hold off
これはスクリプトの一部ですが、このd_K0の値を凡例に入れ、例えばd_K0=1のとき、K=1と表示されるようにしたいです。
0 Comments
Accepted Answer
Takumi
on 24 Jun 2020
以下のようにしてDisplayNameを設定するのはいかがでしょうか.
open_system( 'MPC_SISO_0_block' )
mpc_out = sim( 'MPC_SISO_0_block' );
figure
title( 'Deterioration of the MPC' )
hold on
plot( mpc_out.ScopeData{1}.Values.Time,mpc_out.ScopeData{2}.Values.Data,'LineWidth',2 )
dm = 0.1;
for cnt = -3:3
dp = dm * cnt;
d_K0 = K0 * dp;
num_p = K0 + d_K0;
plant = tf( num_p, den_p );
open_system( 'MPC_SISO_0_block' )
mpc_out = sim( 'MPC_SISO_0_block' );
txt = ['K=',num2str(d_K0)];
plot( mpc_out.ScopeData{1}.Values.Time,mpc_out.ScopeData{2}.Values.Data ,'DisplayName',txt)
% plot( mpc_out.ScopeData{1}.Values.Time,mpc_out.ScopeData{2}.Values.Data*(1+cnt*0.1) )
end
legend show
title( 'MPC K' )
hold off
More Answers (0)
See Also
Categories
Find more on Analysis 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!