Will the program run
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Jan
il 29 Mag 2021
Modificato: Jan
il 29 Mag 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.
Risposte (2)
Image Analyst
il 29 Mag 2021
Modificato: Image Analyst
il 29 Mag 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 Commenti
David Hill
il 29 Mag 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 Commenti
Vedere anche
Categorie
Scopri di più su Startup and Shutdown 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!