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;
0 个评论
采纳的回答
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 Exchange 中查找有关 Title 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!