Plot of Step Function

Zenker, Dr. Matthias Matthias.Zenker at erbe-med.de
Mon Nov 3 11:15:50 CET 2008


This function does not work with vectors.

It does work with single numbers:

-->foo(-1)
 ans  =

  - 1.

-->foo(1)
 ans  =

    1.

-->foo(0.1)
 ans  =

    1.

The plot you want is produced by

-->fplot2d(x,foo)

You can also make foo work with vectors, like

deff('[x]=foo(y)','x = ones(y); x(y<0) = -1')

now you can

-->plot(x,foo(x))

HTH,

Matthias

> -----Original Message-----
> From: Klaus Pieper [mailto:kfpieper at web.de] 
> Sent: Sunday, November 02, 2008 11:26 AM
> To: users at lists.scilab.org
> Subject: Plot of Step Function
> 
> Hi,
> 
> Trying out the example from from 
> http://www.scilab.org/doc/intro/node25.html
> 
> -->deff('[x]=foo(y)','if y>0 then, x=1; else, x=-1; end')
> -->x=-1:0.1:1
> -->plot(x,foo(x))
> 
> I would expect the graph of a step function jumping from -1 
> to 1 at 0. 
> Instead I get a constant function y == -1 for -1 <= x <= 1.
> 
> What's going wrong?
> 
> Klaus
> 
> 
> 

_____________________________________________________________________
ERBE Elektromedizin GmbH
Firmensitz: 72072 Tuebingen
Geschaeftsfuehrer: Christian O. Erbe, Reiner Thede
Registergericht: Stuttgart HRB 380137




More information about the users mailing list