size of empty matrix

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

size of empty matrix

Dmitri A. Sergatskov
Could somebody explain it to my why I get different answers calling
size(b) and "size b" when b is an empty matrix?



octave:60> b=[]
b = [](0x0)
octave:61> size(b)
ans =

   0   0

octave:62> size b
ans =

   1   1


Dmitri.
--



Reply | Threaded
Open this post in threaded view
|

Re: size of empty matrix

Dmitri A. Sergatskov

On Sat, Jun 16, 2018 at 8:07 PM, Dmitri A. Sergatskov <[hidden email]> wrote:
Could somebody explain it to my why I get different answers calling
size(b) and "size b" when b is an empty matrix?



octave:60> b=[]
b = [](0x0)
octave:61> size(b)
ans =

   0   0

octave:62> size b
ans =

   1   1


Dmitri.

​Same with length(), any() ...

​octave:71> b=[]
b = [](0x0)
octave:72> length b
ans =  1
octave:73> length(b)
ans = 0
octave:74> any b
ans = 1
octave:75> any(b)
ans = 0

Dmitri.
--




Reply | Threaded
Open this post in threaded view
|

Re: size of empty matrix

Mike Miller-4
In reply to this post by Dmitri A. Sergatskov
On Sat, Jun 16, 2018 at 20:07:46 -0500, Dmitri A. Sergatskov wrote:
> Could somebody explain it to my why I get different answers calling
> size(b) and "size b" when b is an empty matrix?

Because "size b" is the same as "size ('b')", 'b' is a 1×1 char array.

--
mike



signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: size of empty matrix

Dmitri A. Sergatskov


On Sat, Jun 16, 2018 at 9:19 PM, Mike Miller <[hidden email]> wrote:
On Sat, Jun 16, 2018 at 20:07:46 -0500, Dmitri A. Sergatskov wrote:
> Could somebody explain it to my why I get different answers calling
> size(b) and "size b" when b is an empty matrix?

Because "size b" is the same as "size ('b')", 'b' is a 1×1 char array.


​Thanks.

--
mike

​Dmitri.
--