필터 지우기
필터 지우기

how to plot the phase shift

조회 수: 28 (최근 30일)
학준
학준 2024년 4월 3일
답변: Sandeep Mishra 2024년 8월 16일 9:26
i want this graph but this code didn't work properly after rp is 1
clear;
clc;
tetai = 0:0.01:89.99;
n1 = 1.5;
n2 = 1;
tetac = asind(n2/n1);
tetat = asind(n1*sind(0:0.01:tetac)/n2);
L = length(tetat);
L2 = length(tetai);
tetat(L+1:1:L2) = 90;
rp = (n2*cosd(tetai) - n1*cosd(tetat))./(n1*cosd(tetat) + n2*cosd(tetai));
% treating amplitude coefficients as complex
rp_complex = rp + 1i*0;
phase_rp_deg = angle(rp_complex) * (180/pi); % Calculating phase of rp in degrees
plot(tetai, phase_rp_deg); % Plotting phase of rp as a function of incident angle
ylim([0 180]); % Setting y-axis limit to -180 to 180 to represent phase in degrees
xlabel('Incident Angle (degrees)');
ylabel('Phase of rp (degrees)');
title('Phase of rp vs Incident Angle');
  댓글 수: 2
Anton Kogios
Anton Kogios 2024년 4월 3일
I have no idea about this topic, but something from your code is that you are trying to get the angel of a complex number you made. But you made it have 0 imaginary component, so the angle will just be 0.
Voss
Voss 2024년 4월 3일
... or 180 degrees, for negative real numbers.

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

답변 (1개)

Sandeep Mishra
Sandeep Mishra 2024년 8월 16일 9:26
Hi 학준,
While reproducing the provided code snippet in MATLAB R2024a, I noticed the following observations:
  • The variablerpconsists of all real values.
  • The variablerp_complexis simply the sum ofrpand 0, making "rp_complex" also a real number.
  • The "phase_rp_deg" variable utilizes the MATLAB function "angle" which returns the phase angle for each element in the complex arrayrp_complex.
Based on the above observations, it is evident that the variable "rp_complex" is always a real number. Consequently, "phase_rp_deg" will yield a result of 0 for each complex number of rp_complex.
Additionally, to plot the complex angle graph, you can utilize the following example code:
% Adding complex variable (2i) to real value rp
rp_complex = rp + 1i*2
Refer to the following documentation for more details on the “angle” function.
  1. https://www.mathworks.com/help/releases/R2024a/matlab/ref/angle.html
I hope it helps.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by