bugGNU Octave - Bugs: bug #54576, MATLAB inconsistency when...

 
 

bug #54576: MATLAB inconsistency when assigning to nonexistent variable using subsref (:)

Submitter:  Ceral Paquet <octavebugs>
Submitted:  Sun 26 Aug 2018 05:56:27 PM UTC
   
 
Category:  Interpreter Severity:  2 - Minor
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 28 Aug 2018 03:25:47 PM UTC, comment #4: 

Okay, so the rule seems to be:

1) Any number of colons are allowed on the LHS of assignment
2) The RHS of assignment must be a scalar or vector, not a matrix

Rik <rik5>
Group administrator
Tue 28 Aug 2018 03:59:32 AM UTC, comment #3: 

No problem lowering priority. I just post the bugs when I run into them - typically when trying something off the matlab forums. It's hard to believe people come up with this stuff AND that it's valid syntax. Anyway... ;)

MATLAB

>> clear all
>> a(:,:) = [4:6]
a =
     4     5     6
>> b(1:3,:) = [4:6]
Subscripted assignment dimension mismatch.
>> c(:) = magic (3)
Subscripted assignment dimension mismatch.
>> whos
  Name      Size            Bytes  Class     Attributes

  a         1x3                24  double


Ceral Paquet <octavebugs>
Mon 27 Aug 2018 05:59:14 PM UTC, comment #2: 

Confirmed.  I lowered the severity and the priority since there are workarounds available (don't use ':' indexing on non-existent variables).

This does seem like something worth modifying since I'm sure people code with the ':' even when they don't need it.

Could you also run these tests in Matlab


clear all
a(:,:) = [4:6]
b(1:3,:) = [4:6]
c(:) = magic (3)



Rik <rik5>
Group administrator
Sun 26 Aug 2018 06:07:50 PM UTC, comment #1: 

Cell array: same thing.

>> c{:}=1:10;
>> whos
  Name      Size            Bytes  Class     Attributes

  a         1x10               80  double
  b         1x10               80  double
  c         1x1               192  cell



>> c{:}=1:10;
error: invalid dimension inquiry of a non-existent value


Ceral Paquet <octavebugs>
Sun 26 Aug 2018 05:56:27 PM UTC, original submission:  



MATLAB

>> clear all
>> a(:)=1:10;
>> b(:)=(1:10)';
>> whos
  Name      Size            Bytes  Class     Attributes

  a         1x10               80  double
  b         1x10               80  double



Octave 4.4

>> clear all
>> a(:)=1:10;
error: =: nonconformant arguments (op1 is 0x1, op2 is 1x10)


Ceral Paquet <octavebugs>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by octavebugs (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-08-27 rik5 CategoryNone Interpreter
        Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
        StatusNone Confirmed
        Release4.4.1 dev

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code