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 visualizzazione (ultimi 30 giorni)
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;

Risposta accettata

KALYAN ACHARJYA
KALYAN ACHARJYA il 6 Apr 2020
Modificato: KALYAN ACHARJYA il 6 Apr 2020
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|')

Più risposte (0)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by