number or date? how to know type data

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

number or date? how to know type data

gigiolone123
hi


example:

v=1

vv=23.1.2019

i want to know which type of data it's

v is a number

vv is a date

i use typeinfo but is not correct







--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: number or date? how to know type data

khalil2535
Hello

Try 'whos' for example see this code

>> x=1
x =  1
>> y = 'Hello World!';
>> z = uint8(x);
>> whos
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
        x           1x1                          8  double
        y           1x12                        12  char
        z           1x1                          1  uint8

Total is 14 elements using 21 bytes

>>



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: number or date? how to know type data

Doug Stewart-4
In reply to this post by gigiolone123


On Sun, Mar 10, 2019 at 6:51 AM gigiolone123 <[hidden email]> wrote:
hi


example:

v=1

vv=23.1.2019

i want to know which type of data it's

v is a number

vv is a date

i use typeinfo but is not correct


You can use:
typeinfo
whos
class
and they will tell you that vv is a vector of chars. (a string)
Now if you use this in some code that is looking for a date string
then it will be used as a date but it is just some chars.


 
--
DASCertificate for 206392



Reply | Threaded
Open this post in threaded view
|

Re: number or date? how to know type data

gigiolone123
This post was updated on .
hi all


i think it isn't what i need

i do another example

[NUMARR, TXTARR, RAWARR, LIMITS] = xlsread (percorsoNomeFile,'B1:B100');
%carica i dati dalla tabella excel

P=datenum (TXTARR(3), "dd.mm.yyyy");
C=TXTARR(4)

P=12/01/2011
C=4

P and C are a cell
but P is a date and C is a number

i need to know if it's a number or date





--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: number or date? how to know type data

Andreas Weber-6
Am 10.03.19 um 19:07 schrieb gigiolone123:
> i need to know if it's a number or date

What is a date and what is a number?

dates can be expressed in many, many ways, see "help datestr"
Also string representation of numbers differs in decimal seperators.

If you want some "magical detection" if a string is a number or a date
you hafe to make some assumptions for the string representation.

-- Andy