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

Community Treasure Hunt

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

Start Hunting!

Translated by