How to plot this function?

3 views (last 30 days)
Alejandra on 12 Dec 2014
Answered: Ingrid on 12 Dec 2014
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
temperature = t^(1/4)
% code

Answers (1)

Ingrid on 12 Dec 2014
just create a vector of relevant CO2 concentrations and call your temperature funciton for each value
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));
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


Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!