필터 지우기
필터 지우기

my plot is right for one date but not for other

조회 수: 1 (최근 30일)
mhya k
mhya k 2022년 6월 17일
댓글: Voss 2022년 6월 17일
hello, I should programming this curve with these formula and data (they are on curve) but the finall figuare is right for one and not other,
since I write it for complex number I think something is wrong with my code
btw here my code
close all
clc
clear all
x=0:0.01:pi/2;
nR=3.7;
nI=5.4;
n=nR+nI*i;
mR=0.04;
mI=2.4;
m=mR+mI*i;
z=zeros(length(x),4);
for j=1:length(x);
A=cos(x(j));
B=sqrt((n^2)-((sin(x(j))^2)));
C=(n^2)*(cos(x(j)));
D=cos(x(j));
E=sqrt((m^2)-((sin(x(j))^2)));
F=(m^2)*(cos(x(j)));
rTE1(j)=(A-B)/(A+B);
rTM1(j)=(C-B)/(C+B);
rTE2(j)=(D-E)/(D+E);
rTM2(j)=(F-E)/(F+E);
RTE1(j)= ((rTE1(j))^2);
RTM1(j)= ((rTM1(j))^2);
RTE2(j)= ((rTE2(j))^2);
RTM2(j)= ((rTM2(j))^2);
z(j,1)=RTE1(j);
z(j,2)=RTM1(j);
z(j,3)=RTE2(j);
z(j,4)=RTM2(j);
end
t=x*180/pi;
plot(t,z(:,2),t,z(:,1),t,z(:,4),t,z(:,3))

채택된 답변

Voss
Voss 2022년 6월 17일
You neglected to take the absolute value of ER/E before squaring. (Notice the warning you got that imaginary parts of complex values are ignored when plotting - this tells you the values being plotted were still complex.)
close all
clc
clear all
x=0:0.01:pi/2;
nR=3.7;
nI=5.4;
n=nR+nI*i;
mR=0.04;
mI=2.4;
m=mR+mI*i;
z=zeros(length(x),4);
for j=1:length(x);
A=cos(x(j));
B=sqrt((n^2)-((sin(x(j))^2)));
C=(n^2)*(cos(x(j)));
D=cos(x(j));
E=sqrt((m^2)-((sin(x(j))^2)));
F=(m^2)*(cos(x(j)));
rTE1(j)=(A-B)/(A+B);
rTM1(j)=(C-B)/(C+B);
rTE2(j)=(D-E)/(D+E);
rTM2(j)=(F-E)/(F+E);
% RTE1(j)= ((rTE1(j))^2);
% RTM1(j)= ((rTM1(j))^2);
% RTE2(j)= ((rTE2(j))^2);
% RTM2(j)= ((rTM2(j))^2);
RTE1(j) = abs(rTE1(j))^2;
RTM1(j) = abs(rTM1(j))^2;
RTE2(j) = abs(rTE2(j))^2;
RTM2(j) = abs(rTM2(j))^2;
z(j,1)=RTE1(j);
z(j,2)=RTM1(j);
z(j,3)=RTE2(j);
z(j,4)=RTM2(j);
end
t=x*180/pi;
plot(t,z(:,2),t,z(:,1),t,z(:,4),t,z(:,3))
  댓글 수: 3
mhya k
mhya k 2022년 6월 17일
oh really thank you. I though it wouldn't make any problems.ty for help
Voss
Voss 2022년 6월 17일
You're welcome!

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by