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 ?
2 次查看(过去 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!