Re: [Scilab-users] How to replace Matlab stairs function in Scilab

2015-09-24 Thread Serge Steer
Thers is no stair function but you can obtain this king of plot using
the polyline_properties:

clf;plot(sin(linspace(0,2*%pi,40)))
e=gce();//plot creates an entity of type compound
p=e.children;//the handle on the polyline
p.polyline_style=2; //set stair case mode

Serge Steer

Le 24/09/2015 05:11, Robert McLean MD PhD a écrit :
> So here is what I did for the stairs graph: 
>
> // we are going to make a stair step graphing program in scilab
> //  o--o
> //  o--o|  |
> // ||  o---o
> // oo
> //
> // We take the vector (x1,x2,x3,...,xn) and (y1,y2,y3,...,yn) and instead of 
> // graphing a lines from the data points (x1,y1) to (x2,y2), (x2,y2) to
> (x3,y3),
> // etc., we graph (x1,y1) to (x2,y1) then (x2,y1) to (x2,y2), etc. 
> //
> // the number of graphed points goes from n to 2n-1. 
>
> // (x1,x2,...,xn) 
> // (y1,y2,...,yn) goes to
> // (x1,x2,x2,x3,x3,x4,x4,...)
> // (y1,y1,y2,y2,y3,y3,y4,...)
>
> function stairs(x,y)
> n=length(x);
> x_indices=int((1:2*n-1)/2)+1; // gives 1,2,2,3,3,...,2n-1,2n-1
> x_ss=x(x_indices);  // the stair step graph's x values
> y_indices=int((2:2*n)/2);  // gives 1,1,2,2,...,2n-2,2n-2,2n-1
> y_ss=y(y_indices)
> plot2d(x_ss,y_ss)
> endfunction
>
> // We create an example: 
> n=10;
> x=linspace(0,2,n);
> x=x.*x;  //irregularly spaced x interval points from 0 to 4
> y=sin(x*%pi);
> stairs(x,y)
>
>
>
> --
> View this message in context: 
> http://mailinglists.scilab.org/How-to-replace-Matlab-stairs-function-in-Scilab-tp2615846p4032896.html
> Sent from the Scilab users - Mailing Lists Archives mailing list archive at 
> Nabble.com.
> ___
> users mailing list
> users@lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] How to replace Matlab stairs function in Scilab

2015-09-24 Thread Samuel Gougeon

Hello,

Le 24/09/2015 05:11, Robert McLean MD PhD a écrit :

So here is what I did for the stairs graph:
.../...
function stairs(x,y)
 n=length(x);
 x_indices=int((1:2*n-1)/2)+1; // gives 1,2,2,3,3,...,2n-1,2n-1
 x_ss=x(x_indices);  // the stair step graph's x values
 y_indices=int((2:2*n)/2);  // gives 1,1,2,2,...,2n-2,2n-2,2n-1
 y_ss=y(y_indices)
 plot2d(x_ss,y_ss)
endfunction

// We create an example:
n=10;
x=linspace(0,2,n);
x=x.*x;  //irregularly spaced x interval points from 0 to 4
y=sin(x*%pi);
stairs(x,y)

// either
plot2d2(x,y)

// or..
plot2d(x,y)
e = gce();
e.children(1).polyline_style=2;
// does the same

The polyline_style property enables switching between various plotting 
modes.

help Graphics // http://help.scilab.org/docs/5.5.2/en_US/Graphics.html
help polyline_properties // 
http://help.scilab.org/docs/5.5.2/en_US/polyline_properties.html


HTH
Samuel Gougeon

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] How to replace Matlab stairs function in Scilab

2015-09-23 Thread Robert McLean MD PhD
So here is what I did for the stairs graph: 

// we are going to make a stair step graphing program in scilab
//  o--o
//  o--o|  |
// ||  o---o
// oo
//
// We take the vector (x1,x2,x3,...,xn) and (y1,y2,y3,...,yn) and instead of 
// graphing a lines from the data points (x1,y1) to (x2,y2), (x2,y2) to
(x3,y3),
// etc., we graph (x1,y1) to (x2,y1) then (x2,y1) to (x2,y2), etc. 
//
// the number of graphed points goes from n to 2n-1. 

// (x1,x2,...,xn) 
// (y1,y2,...,yn) goes to
// (x1,x2,x2,x3,x3,x4,x4,...)
// (y1,y1,y2,y2,y3,y3,y4,...)

function stairs(x,y)
n=length(x);
x_indices=int((1:2*n-1)/2)+1; // gives 1,2,2,3,3,...,2n-1,2n-1
x_ss=x(x_indices);  // the stair step graph's x values
y_indices=int((2:2*n)/2);  // gives 1,1,2,2,...,2n-2,2n-2,2n-1
y_ss=y(y_indices)
plot2d(x_ss,y_ss)
endfunction

// We create an example: 
n=10;
x=linspace(0,2,n);
x=x.*x;  //irregularly spaced x interval points from 0 to 4
y=sin(x*%pi);
stairs(x,y)



--
View this message in context: 
http://mailinglists.scilab.org/How-to-replace-Matlab-stairs-function-in-Scilab-tp2615846p4032896.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at 
Nabble.com.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users