Will the program run
12 views (last 30 days)
Show older comments
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 Comment
Jan
on 29 May 2021
Edited: Jan
on 29 May 2021
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.
Answers (2)
Image Analyst
on 29 May 2021
Edited: Image Analyst
on 29 May 2021
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 Comments
David Hill
on 29 May 2021
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 Comments
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!