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!