Discussion:
Double Y axis script in scilab
(too old to reply)
Imane Hachoumi
2019-05-12 22:17:13 UTC
Permalink
Hi everyone,
I need help in executing a script code to get a plot with double Y-axis;

here is the code that I'm working on:
(Nb: please if you notice any error, don't hesitate to tell me, thank you)

function []=Batch()
y0 = [1; 200; 0]; // CX0, CS0,CE0;
x0=[1; 100; 0];
t0 = 0;
t = linspace(0,10,100);


function [ydot]=MyFun(t,y)
Yxs=0.038;Yes=0.436; mumax=0.45;Ks=33.78;
Kis=33.96; CEmax=83.96; n=0.89;

mu = mumax*(y(2)/(Ks+y(2)+((y(2)^ 2)/Kis)))*(1-(y(3)/CEmax)^n);
ydot = [ mu * y(1);//CX0
(mu * y(1)/Yxs);//CS0
Yes/Yxs * mu * y(1)];//CE0
endfunction

y = ode(y0,t0,t,MyFun);
plot(t,y(2,:),'kx-',t,y(1,:),'ro-');
xlabel ('time (h)');ylabel('Cs(g.L-1)');zlabel('Ce(g.L-1)left');
legend('Ce','Cs');
endfunction
Vincent Belaïche
2019-05-30 11:11:03 UTC
Permalink
Post by Imane Hachoumi
Hi everyone,
I need help in executing a script code to get a plot with double Y-axis;
(Nb: please if you notice any error, don't hesitate to tell me, thank you)
function []=Batch()
y0 = [1; 200; 0]; // CX0, CS0,CE0;
x0=[1; 100; 0];
t0 = 0;
t = linspace(0,10,100);
function [ydot]=MyFun(t,y)
Yxs=0.038;Yes=0.436; mumax=0.45;Ks=33.78;
Kis=33.96; CEmax=83.96; n=0.89;
mu = mumax*(y(2)/(Ks+y(2)+((y(2)^ 2)/Kis)))*(1-(y(3)/CEmax)^n);
ydot = [ mu * y(1);//CX0
(mu * y(1)/Yxs);//CS0
Yes/Yxs * mu * y(1)];//CE0
endfunction
y = ode(y0,t0,t,MyFun);
plot(t,y(2,:),'kx-',t,y(1,:),'ro-');
xlabel ('time (h)');ylabel('Cs(g.L-1)');zlabel('Ce(g.L-1)left');
legend('Ce','Cs');
endfunction
Hello,

Could you please clarify the meaning of « double y axis ».

Do you mean that you would like to have two legends for the y axis, one
named 'Cs(g.L-1)', and one named 'Ce(g.L-1)left' ?

Why don't you just write something like

ylabel('Cs(g.L-1) in black, Ce(g.L-1)left in red' )

You could also play with xstring to place some tag somewhere.

function []=Batch()
y0 = [1; 200; 0]; // CX0, CS0,CE0;
x0=[1; 100; 0];
t0 = 0;
t = linspace(0,10,100);

function [ydot]=MyFun(t,y)
Yxs=0.038;Yes=0.436; mumax=0.45;Ks=33.78;
Kis=33.96; CEmax=83.96; n=0.89;

mu = mumax*(y(2)/(Ks+y(2)+((y(2)^ 2)/Kis)))*(1-(y(3)/CEmax)^n);
ydot = [ mu * y(1);//CX0
(mu * y(1)/Yxs);//CS0
Yes/Yxs * mu * y(1)];//CE0
endfunction

y = ode(y0,t0,t,MyFun);
plot(t,y(2,:),'kx-',t,y(1,:),'ro-');
a = gca();
xlabel (a,'time (h)');
ylabel(a,'Ce(g.L-1)left','color','red');
yl = a.y_label;
xstring(yl.position(1)+1,yl.position(2),'Cs(g.L-1)',-90);
legend('Ce','Cs');
endfunction

Loading...