필터 지우기
필터 지우기

How to plot angle (in radians) versus phase shift?

조회 수: 4 (최근 30일)
Rahul
Rahul 2023년 6월 20일
댓글: David Goodmanson 2023년 6월 20일
Hi,
I want a profile with phase angle plotted against angle in radians.
Presently I have a code with phase angle plotted against a linear distance which is as below.
Need your valuable advice how to do the necessary changes in this code.
Also I need to determine its slope.
Sincerely,
rc
clc;
clear;
phi_1 = [0.1724*pi 0.1472*pi 2.18*pi 2.25*pi 4*pi 3.588*pi 1.012*pi 4.112*pi 4.31*pi 4.25*pi 0.832*pi];
x1 = linspace(0,1,11);
coefficients1=polyfit(x1,phi_1,1);
slope1=coefficients1(1);
intercept1=coefficients1(2);
figure(1)
hold on
plot(x1,phi_1,'o')
plot([0 1],intercept1 + slope1*[0 1])
  댓글 수: 1
David Goodmanson
David Goodmanson 2023년 6월 20일
Hi Rahul,
you can shorten up the code by eliminating the slope and intercept calculations and plotting the line with
plot([0 1],polyval(coefficients1,[0 1])).
It's not possible to say anything about plotting using angle without knowing the lower and upper limits of the angle. Anyway, any kind of straight line fit to this data looks pretty dubious.

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

채택된 답변

Naman
Naman 2023년 6월 20일
Hi Rahul,
To plot phase angle against angle in radians instead of linear distance, you will need to replace the x-axis values with angle values. Assuming you want to plot angle values from 0 to 2*pi, you can generate them using the linspace function and modify the plot accordingly. Here's the modified code:
clc;
clear;
phi_1 = [0.1724*pi 0.1472*pi 2.18*pi 2.25*pi 4*pi 3.588*pi 1.012*pi 4.112*pi 4.31*pi 4.25*pi 0.832*pi];
theta = linspace(0, 2*pi, numel(phi_1)); % generate angle values
coefficients1 = polyfit(theta, phi_1, 1);
slope1 = coefficients1(1);
intercept1 = coefficients1(2);
figure(1)
hold on
plot(theta, phi_1, 'o') % plot phase angle against angle in radians
plot([0 2*pi], intercept1 + slope1 * [0 2*pi]) % plot linear fit
xlabel('Angle (radians)') % update x-axis label
ylabel('Phase angle') % update y-axis label

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by