フィルターのクリア

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 Center および File ExchangeAnnotations についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by