[Scilab-users] Plotting -- why wrong values on the x and y axes?

Radovan Omorjan omorr at uns.ac.rs
Wed Jul 9 08:52:46 CEST 2014


Compare these two different things

This
---------------------------
x=[0:0.1:2*%pi]';
x($), sin(x($)), sin(2*%pi)
ans  =

     6.2
  ans  =

   - 0.0830894
  ans  =

   - 2.449D-16
----------------------------
and this
---------------------------
x=linspace(0,2*%pi)';
x($), sin(x($)), sin(2*%pi)
ans  =

     6.2831853
  ans  =

   - 2.449D-16
  ans  =

   - 2.449D-16
----------------------------
$ will give you the index of the last vector element.
Have in mind that colon operator and linspace() work differently.

-->0:0.1:0.99
  ans  =

     0.    0.1    0.2    0.3    0.4    0.5    0.6    0.7    0.8 0.9

-->linspace(0,0.99,10)
  ans  =

     0.    0.11    0.22    0.33    0.44    0.55    0.66    0.77 0.88    
0.99

Hope this helped.

Regards,
Radovan


On 7/9/2014 8:15 AM, tanthiamhuat wrote:
> yes, I understand now. how about second part of the question that
>
> x=[0:0.1:2*%pi]';
> y=sin(x);plot(x,y)
> why does the above 2 lines give a plot which does not touch the x-axis at
> x=2*pi? also, it seems not to be exact at (0,0).
> see http://postimg.org/image/4t4pcqub5/
>
>
>
> --
> View this message in context: http://mailinglists.scilab.org/Plotting-why-wrong-values-on-the-x-and-y-axes-tp4030855p4030857.html
> Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>



---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20140709/a737139a/attachment.htm>


More information about the users mailing list