[Scilab-users] Why plot doesn't work on integers
Federico Miyara
fmiyara at fceia.unr.edu.ar
Sat Feb 2 09:42:24 CET 2019
Dear all,
I know it is better to use plot2d, but I wonder why plot works
differently from plot2d when one of the variables is integer.
Consider this code
// Generate x axis with real (double) numbers
x = (1:20)/20
// Generate y axis with random integers
y = iconvert(100*rand(1,20),2)
// Plot y vs x
plot(x, y)
The plot represents x vs its index, which is not the intended behavior.
Replacing plot(x,y) with plot2d(x,y) we get the correct plot.
The documentation of both plot and plot2d requires "real" matrix or
vector. It seems that plot takes it a bit too literally (as a data type)
while plot2d adheres to the mathematical meaning of "real" (considering
integer numbers as a subset of real numbers).
Is there a fundamental reason for this?
The problem arises when one retrieves integers from a file without
converting them to double (which requires much more memory).
Regards,
Federico Miyara
---
El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
https://www.avast.com/antivirus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20190202/e7501e1f/attachment.htm>
More information about the users
mailing list