• Double Y axis script in scilab

    From Imane Hachoumi@21:1/5 to All on Sun May 12 15:17:13 2019
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?iso-8859-1?Q?Vincent_Bela=EFche?=@21:1/5 to Imane Hachoumi on Thu May 30 13:11:03 2019
    Copy: vincent.belaiche@gmail.com (=?iso-8859-1?Q?Vincent_Bela=EFche?=)
    Copy: hachoumi.imane@gmail.com (Imane Hachoumi)

    Imane Hachoumi <hachoumi.imane@gmail.com> writes:

    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

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)