how to store value computed from into array and plot the value in graph
13 ビュー (過去 30 日間)
古いコメントを表示
In given code the value ss has to be incremented from 0 to n values and to be stored as variable.
and for every value of ss the value of a4 and b3 need to be caluclated and stored as variable.
at last the plot must be drawn between SS vs A4 and B3.
Could anyone please sugesst some to idea to it?????
w=100 %land subsection width
s=100 %Edge to edge separation
h=62 %dielectric thickness
er=4.7; %Dieelctric Constant
vo=3e8;
pi=3.14;
for ss=0:1:50;
e0=8.85e12;
T=h/ss;
D=s/ss;
a1=(ss/(2*pi*e0));
a2=0.5*(2*D-1)*log(2*D-1) - (2*D-1)*log(2D+1) - 0.5*(2*D-1)*log((2*D-1).^2 + (4*T).^2) + 0.5*(2*D-1)*log((2*D-1).^2 + (4*T).^2) + T*(atan((2*D+1)/4*T)- atan((2*D-1)/4*T));
a3=a1*a2;
b1=0.5* log(1+(4*T).^2) + 4*T*atan(1/(4*T));
b2=a1*b1;
a4=abs(a3)
b3=abs(b2)
end
0 件のコメント
採用された回答
Jakob B. Nielsen
2020 年 1 月 15 日
編集済み: Jakob B. Nielsen
2020 年 1 月 15 日
Issue 1 is that your first loop iteration sees ss=0, and then you have s/ss... Can't divide by 0! :)
Aside from that, you simply need to use indexing. Let me give you an example here, and you can easily apply that to your code.
for ss=1:51 %you dont need to specify steps of 1 - only specify steps if they are different from 1 :)
ss_save(ss)=ss; %save the iteration number
a4(ss)=ss*2; %just some simple example math
b3(ss)=a4(ss)*1.2;
end
plot(ss_save,a4);
hold on %hold on makes the 2nd plot appear in the same window as the first plot. If you dont want this, use hold off instead.
plot(ss_save,b3);
Your result will be (in this example) two vectors named ss_save and a4, both with dimension 1x51 and each index will have that loop iterations value. So a4(17) will have the 17th loop iteration value. You cannot index 0s though, so your for loop cant be for ss=0:50.
(Side info; you can, in a simple case like this, also simply initialise your "ss_save" vector before (or even after) the for loop - but doing it within the loop is just fine too, and gives you more flexibility.
ss_save=1:1:51;
2 件のコメント
Jakob B. Nielsen
2020 年 1 月 15 日
編集済み: Jakob B. Nielsen
2020 年 1 月 15 日
You initialise s outside your for loop to be s=100, but then inside your loop you have:
D(ss)=s/ss;
s=2*pi*e0;
Giving a new, permanent value to s. That is why your first iteration gives D(1) = 100, and the remaining goes completely bonkers :)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Labels and Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!