plot a graph of year vs rate
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
so i have a code :
function ydot= fossil_fuels(t,y)
p = y(1); sigmas = y(2); sigmad = y(3); alphas = y(4); alphad = y(5);
r = [0.0 0.0 1.0 4.0 5.0 8.0 10.0 10.5 10.0 8.0 3.5 2.0 0.0 0.0];
yr = [1000 1850 1950 1980 2000 2050 2080 2100 2120 2150 2225 2300 2500 5000];
f = pchip(yr,r);
d = 8.65;
u1 = 4.95 * 10^2;
u2 = 4.95 * 10^-2;
vs = 0.12;
vd = 1.23;
w = 10^-3;
k1 = 2.19 * 10^-4;
k2 = 6.12 * 10^-5;
k3 = 0.997148;
k4 = 6.79 * 10^-2;
hs = (sigmas - (sigmas^2 - k3*alphas*(2*sigmas - alphas)))^0.5/k3;
cs = (alphas - hs)/2;
ps = k4*hs^2/cs;
ydot = [(ps - p)/d + ppval(f,t)/u1; 1/vs * ((sigmad-sigmas)*w - k1 - u2*(ps-p)/d);...
1/vd(k1-(sigmad-sigmas)*w);(1/vs) * ((alphad - alphas) * w-k2);...
1/vd * (k2-(alphad - alphas)*w)];
using the plot command to plot yearly values in the variable u against the rates in the variable v. The output of pchips may be evaluated using ppval ( to evaluate the interpolated function at these time values).
this is what i have done :
u = yr;
v = r;
plot(u,v)
but it gives me an error of
Not enough input arguments.
Error in fossil_fuels (line 2)
p = y(1); sigmas = y(2); sigmad = y(3); alphas = y(4); alphad = y(5);
2 Commenti
Walter Roberson
il 31 Mag 2019
How are you invoking fossil_fuels ? Are you just clicking the green Run button?
Risposte (1)
Walter Roberson
il 31 Mag 2019
You cannot invoke that code by just clicking the green run button. You need to invoke it from other code, or by going to the command line and calling upon it passing in appropriate input values. For example,
p = 10*rand;
alphas = rand;
alphad = rand;
sigmas = randn();
sigmad = randn();
t = 0;
ydot = fossil_fuels(t, [p, sigmas, sigmad, alphas, alphad]);
Normally you would have ode45 invoke the routine. For example,
tspan = [0 10];
x0 = [p, sigmas, sigmad, alphas, alphad];
ode45(@fossil_fuels, tspan, x0)
0 Commenti
Vedere anche
Categorie
Scopri di più su Annotations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!