q=[1, 4, 10, 50, 100];
for j=1:length(q)
for i=1:q(j)
Dq=D(1:q(j),1:q(j));
Vq=V(1:q(j),1:q(j));
Cq=C(1:q(j));
Bq=B(1:q(j));
end
S = logspace(-8,4,500);
k=1;
for p=S
Y(k)=Cq*Vq*inv(1i*p*eye(q(j))-Dq)*inv(Vq)*Bq;
k=k+1;
end
figure;
hold on
subplot(2,1,1);
semilogx(S,real(Y));
grid; ylabel('|H(j\omega)|');
title(['Bode Plot: Magnitude Response (Real)q=',q(j)]);
subplot(2,1,2);
semilogx(S,imag(Y));
grid; xlabel('\omega (rad/sec)'); ylabel('\angleH(j\omega)');
title(['Bode Plot: Phase Response (Imaginary) q = ',q(j)]);
end
我想在标题中打印q
的值,例如q=1
,... q=100
。代码工作正常但它没有在标题中显示q
的值,特别是我正在绘制的q
的值。如何解决这个问题?
答案 0 :(得分:1)
要为包含数字值的标题创建字符串,请使用num2str
:
title(['Bode Plot: Phase Response (Imaginary) q = ' num2str(q(j))]);