[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #59113] Warning when String property of a uico

From: Rik
Subject: [Octave-bug-tracker] [bug #59113] Warning when String property of a uicontrol is a char array
Date: Mon, 14 Sep 2020 13:57:01 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36

Follow-up Comment #3, bug #59113 (project octave):

The results for strcmp are what I would expect.  There might be a bug report
open about this already, otherwise we could create one to discuss the
difference.  Take the second case as being the most straightforward of what is
going on.

s = { ['a';'b'], 'a' }

This creates a 1x2 cell array where the first entry is a 2x1 char matrix and
the second is a 1x1 char matrix.

Now try

strcmp (s, 'a')

Octave iterates over the cell array.  For the first entry it finds a multi-row
char matrix and warns that only the first row will be considered.  That first
row is 'a' so the strcmp matches.  The second entry is 'a' by itself which
also matches so the return value is "1 1".

Matlab, however, seems to convert a char matrix to a 1xN string before
comparison.  The code equivalent is

str = char_mat(:).'

You can see that by testing this

strcmp (s, 'ab')

Matlab will return "1 0" while Octave returns "0 0".


Reply to this item at:


  Message sent via Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]