Help!! I'm trying to plot a function where the output changes with different values of the array. my for loop works, I can see the values changing. I just have trouble with plotting it. I get a graph with nothing in it! any help is appreciated!

조회 수: 1 (최근 30일)
gamma=0.268;
dt=0.05;
T=10;
t=0:dt:T
for tt=0:dt:T
x=gamma*sqrt(((1-cos(0.7255*t)).^2+(sin(0.7255*t)).^2)/((1-gamma*cos(0.7255*t)).^2+(gamma^2)*(sin(0.7255*t)).^2))
y=abs(x)
end
figure;
hold on;
grid on;
plot(t,y);
title('1b)')
xlabel('frequncy (GHz)')
ylabel('|Gamma|')
hold off;

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 4월 6일
편집: KALYAN ACHARJYA 2020년 4월 6일
gamma=0.268;
dt=0.05;
T=10;
t=0:dt:T
for tt=1:length(t)
x=gamma*sqrt(((1-cos(0.7255*t(tt))).^2+(sin(0.7255*t(tt))).^2)/((1-gamma*cos(0.7255*t(tt))).^2+(gamma^2)*(sin(0.7255*t(tt))).^2))
y(tt)=abs(x);
end
figure;
plot(t,y); grid on;
title('1b)')
xlabel('frequncy (GHz)')
ylabel('|Gamma|')
More: No Loop is required here, try
gamma=0.268;
dt=0.05;
T=10;
t=0:dt:T;
x=gamma*sqrt((1-cos(0.7255*t).^2+(sin(0.7255*t)).^2)./((1-gamma*cos(0.7255*t)).^2+(gamma^2)*(sin(0.7255*t)).^2));
y=abs(x);
figure;
plot(t,y); grid on;
title('1b)')
xlabel('frequncy (GHz)')
ylabel('|Gamma|')

추가 답변 (0개)

카테고리

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