Having issues plotting with imaginary values. Need help checking results.

조회 수: 12 (최근 30일)
Aggie1313
Aggie1313 2016년 11월 30일
답변: KSSV 2016년 11월 30일
The question I am trying to complete is stated in the given image. This is what I have so far but I'm thinking it is incorrect and could use some help debugging. I need to plot H vs Omega
clc
clear all
fr=linspace(0,4,100);
dr1 = 0;
dr2 = 0.1;
dr3 = 0.2;
dr4 = 0.4;
dr5 = 0.5;
H1=1./((1-fr.^2)+(2*dr1*fr).^2).^(0.5)
omega1 = (180/pi)*atan((2*dr1*fr)./(1-fr.^2))
plot(imag(H1),omega1)
hold on
H2=1./((1-fr.^2)+(2*dr2*fr).^2).^(0.5)
omega2 = (180/pi)*atan((2*dr2*fr)./(1-fr.^2))
plot(imag(H2),omega2)
H3=1./((1-fr.^2)+(2*dr3*fr).^2).^(0.5)
omega3 = (180/pi)*atan((2*dr3*fr)./(1-fr.^2))
plot(imag(H3),omega3)
H4=1./((1-fr.^2)+(2*dr4*fr).^2).^(0.5)
omega4 = (180/pi)*atan((2*dr4*fr)./(1-fr.^2))
plot(imag(H4),omega4)
H5=1./((1-fr.^2)+(2*dr5*fr).^2).^(0.5)
omega5 = (180/pi)*atan((2*dr5*fr)./(1-fr.^2))
plot(imag(H5),omega5)

답변 (1개)

KSSV
KSSV 2016년 11월 30일
N = 100 ;
fr=linspace(0,4,N);
dr = [0; 0.1; 0.2; 0.4; 0.5];
H = zeros(length(dr),N) ;
omega = zeros(length(dr),N) ;
for i = 1:length(dr)
H(i,:)=1./((1-fr.^2)+(2*dr(i)*fr).^2).^(0.5) ;
omega(i,:) = (180/pi)*atan((2*dr(i)*fr)./(1-fr.^2)) ;
end
figure ;loglog(fr,abs(H),'r') ;
figure ; plot(fr,omega,'b') ;
Go through the text book of the concepts once, find out what to plot w.r.t what. I did it long ago and unable to recollect.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by