how to find bode plot,phase magnitude plot and template in control system?

z=1:0.5:10; a=1:0.5:5; num=kron(z,ones(1,length(a))); i=1:length(a); deno=zeros(9,3); deno(i,1)=1; deno(i,2)=a(i); den=repmat(deno,length(z),1); n=numel(num); for m=1:n sys(m)=tf(num(m),den(m,:)); end

댓글 수: 1

In the above solution which u have given for phase magnitude plot is it for 171 transfer functions or for one transfer function?

댓글을 달려면 로그인하십시오.

 채택된 답변

This works, although you will have to plot 171 figures to see each of them with any detail. (You would have to have a very large monitor to see them all as the bode function plots them, since it plots an array of (2x171) subplots in one figure.)
The Code
[mag,phs,wout] = bode(sys);
Magnitude = squeeze(mag);
Phase = squeeze(phs);
figure(1)
subplot(2,1,1)
plot(wout,20*log10(Magnitude(1,:)))
title('Magnitude (dB)')
grid
subplot(2,1,2)
plot(wout,Phase(1,:))
title('Phase (°)')
grid
The ‘template’ is a Simulink function you will have to do yourself, since you have to specify how you want it.

댓글 수: 1

‘In the above solution which u have given for phase magnitude plot is it for 171 transfer functions or for one transfer function?’
The code is for all of them. It plots only one, because letting the bode function plot them produces an unreadable collection of subplots. To get any useful information from the plots, you will have to plot them one-by-one. Plot as many as you like.
You can do that in a loop:
for k1 = 1:171
figure(k1)
subplot(2,1,1)
plot(wout,20*log10(Magnitude(k1,:)))
title('Magnitude (dB)')
grid
subplot(2,1,2)
plot(wout,Phase(k1,:))
title('Phase (°)')
grid
end

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

while running this solution,i got this error "Error in dcmotor (line 18)
plot(w,20*log10(Magnitude(k1,:)))"
close all; clear all; clc tic; w=[.001 .0036 .0126 .0464 .1668 .5995 2.1544 7.7426 27.8256 100 200]; for k=1:0.5:10 for a=1:0.5:5 num=k; den=[1 a 0]; sys=tf(num,den); end end bode(sys,w); grid on for k1 = 1:171 figure(k1) subplot(2,1,1) plot(w,20*log10(Magnitude(k1,:))) title('Magnitude (dB)') grid subplot(2,1,2) plot(w,Phase(k1,:)) title('Phase (°)') grid end time=toc

댓글 수: 1

You have to call the bode function with outputs:
[mag,phs,wout] = bode(sys,w);
Magnitude = squeeze(mag);
Phase = squeeze(phs);
I have no idea what you are doing with your code.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Plot Customization에 대해 자세히 알아보기

제품

질문:

2017년 7월 10일

댓글:

2017년 7월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by