필터 지우기
필터 지우기

plot a graph of year vs rate

조회 수: 2 (최근 30일)
NIMA RAHMANI MEHDIABADI
NIMA RAHMANI MEHDIABADI 2019년 5월 31일
답변: Walter Roberson 2019년 5월 31일
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
Walter Roberson
Walter Roberson 2019년 5월 31일
How are you invoking fossil_fuels ? Are you just clicking the green Run button?
NIMA RAHMANI MEHDIABADI
NIMA RAHMANI MEHDIABADI 2019년 5월 31일
yes

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2019년 5월 31일
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)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by