Why does it not plot the function?
1 回表示 (過去 30 日間)
古いコメントを表示
In the following series of functions, only the 1st one is being plotted. I don't understand why the others don't appear. Could you help?
function ode_metabolism
tau1= 2; %%1st time const of neural feedback
tau2= 4;
t=0:0.1:1000; % time scale
initial_xm = 0;
initial_dxmdt = 0;
[t,x]=ode45( @Fm, t, [initial_xm initial_dxmdt] );
%
% plot(t,x(:,1));
% xlabel('t'); ylabel('xm');
function dxmdt=Fm(t,x)
dxdt_1 = x(2);
dxdt_2 = (-tau2*x(2) - x(1)+eps*0.5)/tau1^2;
dxmdt=[dxdt_1; dxdt_2];
end
end
%%flow
function ode_q
q=12;
q_b=12.5;
G_q= 3; %%gain of flow based feedback mechanism
tau_q= 20; %%[s] time const of flow based feedback mechanism
t=0:0.1:100; % time scale
initial_xq = 0;
[t,xq]=ode45( @Fq, t, [initial_xq] );
plot(t,xq(:,1));
xlabel('t'); ylabel('xq');
function dxqdt=Fq(t,xq)
dxdt1 = (-xq +G_q* (q-q_b)/q_b)/tau_q;
dxqdt=[dxdt1];
end
end
0 件のコメント
採用された回答
OCDER
2017 年 10 月 13 日
編集済み: OCDER
2017 年 10 月 13 日
Only the 1st function, ode_metabolism, is called since it is considered the main function.
Your ode_q function is viewed as a local function , which must be summoned by the main function, ode_metabolism, to be used.
To fix this, either have ode_metabolism call ode_q, OR make another main function that calls ode_metabolism and ode_q as local functions, like this:
function ode_main
ode_metabolism;
ode_q;
end
function ode_metabolism
...
end
function ode_q
...
end
その他の回答 (1 件)
Image Analyst
2017 年 10 月 13 日
You commented out the plot() call in ode_metabolism(), and the function ode_q() never gets called so the plot() in there never gets called either.
2 件のコメント
Image Analyst
2017 年 10 月 13 日
It's because the ode_q() function is never called by your code, so how could that plot ever get called?
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!