Will the program run
12 次查看(过去 30 天)
显示 更早的评论
e=8.854*10^(-12); for l=1:1:5 , z=[0.00478 0.00828 0.011 0.015 0.018] for s=[19.5101 30.1388 38.7676 47.6357 64.1442] , h=[120000 200000 380000 540000 680000] , o=[0.9990 0.9961 0.9940 0.9982 0.9991] f=7.486.*sqrt((l.*(l+1)).*((1-(h/6378.1))/(o+j.*(s/(e.*2.*pi.*z))))); plot(h,f); end xlabel('schumann resonance frequency f'); ylabel('altitude h'); title('SR');
1 个评论
Jan
2021-5-29
编辑:Jan
2021-5-29
I've removed the duplicate question.
Please format your codeto make it readable: One command per line and use the Code style selected from the toolbar. If you have done this, you can simply press the green triangle to let the code run directly here in the forum. Then you can see the answer by your own.
回答(2 个)
Image Analyst
2021-5-29
编辑:Image Analyst
2021-5-29
No it will not run.
- You have no closing end on your (badly-named) l loop
- You have no hold on after plot(h, f)
- You have not defined j. If it's the imaginary variable use 1j like the editor hint tells you.
- Not sure what your s loop is doing. It will iterate over each value of s one at a time but in your formula you're using the whole vector of s values.
- the (also badly-named) o is in the denominator (along with vector s) and it's a vector not a scalar so you'd need to have ./ instead of / to do an elemente-by-element divide.
e=8.854*10^(-12);
for l=1:1:5
z=[0.00478 0.00828 0.011 0.015 0.018]
for s=[19.5101 30.1388 38.7676 47.6357 64.1442]
h=[120000 200000 380000 540000 680000]
o=[0.9990 0.9961 0.9940 0.9982 0.9991]
f=7.486.*sqrt((l.*(l+1)).*((1-(h/6378.1))/(o+j.*(s/(e.*2.*pi.*z)))));
plot(h,f);
end
xlabel('schumann resonance frequency f');
ylabel('altitude h');
title('SR');
Perhaps this is closer but I really have no idea what you want to do:
e=8.854*10^(-12);
allz=[0.00478 0.00828 0.011 0.015 0.018]
allh=[120000 200000 380000 540000 680000]
allo=[0.9990 0.9961 0.9940 0.9982 0.9991]
alls=[19.5101 30.1388 38.7676 47.6357 64.1442]
j = 42;
for l = 1 : 5
for k = 1 : length(alls)
thiss = alls(k);
thiso = allo(k);
thisz = allz(k);
thish = allh(k);
f = 7.486.*sqrt((l.*(l+1)).*((1-(thish/6378.1)) ./ (thiso+j.*(thiss ./ (e.*2.*pi.*thisz)))));
plot(thish,f, 'b.');
hold on;
end
xlabel('Schumann resonance frequency f');
ylabel('Altitude h');
title('SR');
end
grid on;
0 个评论
David Hill
2021-5-29
No loops needed. I assume your j is imaginary and that you only want to plot the real part of f.
e=8.854*10^(-12);
l=1:5;
z=[0.00478 0.00828 0.011 0.015 0.018];
s=[19.5101 30.1388 38.7676 47.6357 64.1442];
h=[120000 200000 380000 540000 680000];
o=[0.9990 0.9961 0.9940 0.9982 0.9991];
f=7.486*sqrt((l.*(l+1)).*((1-(h/6378.1))./(o+1i*(s./(e*2*pi*z)))));
plot(h,real(f));
xlabel('schumann resonance frequency f');
ylabel('altitude h');
title('SR');
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!