How to plot this function?
5 ビュー (過去 30 日間)
古いコメントを表示
I have this function that allows me to work out what the temperature is according to CO2. However, I wanted to know how could I plot temperature as a function of CO2 concentrations.
This is the function that tells me how to get from a certain CO2 value to a Temperature value for that CO2 however I'd like to plot it as a graph.
if true
function temperature(carbon)
s0=1367.6; %constant parameter
a=0.3; %albedo
A=-129.2684; %constant
B=142.6046; %another constant
eps=A/(B-carbon);%green house value as a function of CO2 concentration
sigma=5.67*(10^(-8)); % constant parameter
t=((s0*(1-a))/(eps*(4*sigma)));
temperature = t^(1/4)
end
% code
end
0 件のコメント
回答 (1 件)
Ingrid
2014 年 12 月 12 日
just create a vector of relevant CO2 concentrations and call your temperature funciton for each value
so:
carbon = 1:10:1000; % place here your relevant concentrations that you want to plot
temperatureY = zeros(length(carbon),1);
for ii = 1:length(carbon)
temperatureY(ii) = temperature(carbon(ii));
end
plot(carbon,temperatureY);
you need the for loop here because your function cannot deal with vectors so if speed of your code is an issue this is something you can still improve
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!