whenever i use individual value of time (Tv) the output function (F) giving right value but using time in the form of loop ,output function gives wrong result for all.How to fix this ?
조회 수: 1 (최근 30일)
이전 댓글 표시
clc
clear all
c1 = 3.742*10.^8;
c2 = 1.43878*10.^4;
sigma = 5.67*10.^-8;
lamda_1 = 8;
lamda_2 = 13;
Tv = -10:5:30;
F = zeros(size(Tv));
count = 1;
for T=Tv
fun = @(lambda) c1./(lambda.^5.*(exp(c2./(lambda * T+273)))-1);
F(count) = integral(fun,lamda_1,lamda_2)./(sigma.*(T+273)^4)
plot(T, F(count), '+', 'MarkerSize', 10, 'LineWidth', 2)
hold on
grid
count = count + 1;
end
xlabel('Temperature')
ylabel('Fraction in atmospheric window)')
title('Fraction of the radiation emitted in the atmospheric window as a function of temperature')
legend('T=-10','T=-5','T=0','T=5','T=10','T=15','T=20','T=25','T=30')
hold off
댓글 수: 0
채택된 답변
Alan Stevens
2020년 9월 29일
You missed a set of brackets connecting TV to 273.
c1 = 3.742*10.^8;
c2 = 1.43878*10.^4;
sigma = 5.67*10.^-8;
lamda_1 = 8;
lamda_2 = 13;
Tv = -10:5:30;
F = zeros(size(Tv));
count = 1;
for T=Tv
fun = @(lambda) c1./(lambda.^5.*(exp(c2./(lambda *(T+273))))-1); %%%%%%%
F(count) = integral(fun,lamda_1,lamda_2)./(sigma.*(T+273)^4);
plot(T, F(count), '+', 'MarkerSize', 10, 'LineWidth', 2)
hold on
count = count + 1;
end
grid
xlabel('Temperature')
ylabel('Fraction in atmospheric window)')
title('Fraction of the radiation emitted in the atmospheric window as a function of temperature')
legend('T=-10','T=-5','T=0','T=5','T=10','T=15','T=20','T=25','T=30')
hold off
댓글 수: 6
Alan Stevens
2020년 9월 30일
Or, if you don't want the crosses at all:
c1 = 3.742*10.^8;
c2 = 1.43878*10.^4;
sigma = 5.67*10.^-8;
lamda_1 = 8;
lamda_2 = 13;
Tv = -10:30;
F = zeros(size(Tv));
count = 1;
for T=Tv
fun = @(lambda) c1./(lambda.^5.*(exp(c2./(lambda *(T+273))))-1);
F(count) = integral(fun,lamda_1,lamda_2)./(sigma.*(T+273)^4);
count = count + 1;
end
plot(Tv,F)
grid
xlabel('Temperature')
ylabel('Fraction in atmospheric window)')
title('Fraction of the radiation emitted in the atmospheric window as a function of temperature')
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!