フィルターのクリア

Plotting a function with for loop

1 回表示 (過去 30 日間)
Kushagra Kirtiman
Kushagra Kirtiman 2022 年 8 月 19 日
回答済み: Star Strider 2022 年 8 月 19 日
I want to plot Function G with k but function G depends on the values of i which is incremented by 1. Is there a way to plot this function in MATLAB. I have written the code but it is not working. Any help is appreciated
a=100.400
b=230.033
c1=1
c2=4
k=1:100
for i =1:1:100
G=1+c1*exp(-j*i*a)+c2*exp(-j*i*b)
end
plot(G,k)

回答 (1 件)

Star Strider
Star Strider 2022 年 8 月 19 日
Subscript ‘G’ to save it as a vector —
a=100.400;
b=230.033;
c1=1;
c2=4;
k=1:100;
for i =1:1:100
G(i)=1+c1*exp(-j*i*a)+c2*exp(-j*i*b);
end
figure
plot(real(G),k)
hold on
plot(imag(G),k)
hold off
grid
legend('Re','Im')
xlabel('G')
ylabel('k')
figure
plot(k,real(G))
hold on
plot(k,imag(G))
hold off
grid
legend('Re','Im')
xlabel('k')
ylabel('G')
Make appropriate changes to get the result you want.
.

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by