Skip to content

solve returns cell array of structs, which differs from SMT #1330

@MaxGaspa

Description

@MaxGaspa

Using latest version of Octave and symbolic package on Windows 10

>> pkg load symbolic
>> syms x y z a
Symbolic pkg v3.2.2: Python communication link active, SymPy v1.10.1.
>> eqna = x + y + z == 0
eqna = (sym) x + y + z = 0
>> eqnb = 2*x*y-4==0
eqnb = (sym) 2*x*y - 4 = 0
>> S = solve(eqna,eqnb)
S =
{
  [1,1] =

    scalar structure containing the fields:

      x =

        <class sym>

      y =

        <class sym>


  [1,2] =

    scalar structure containing the fields:

      x =

        <class sym>

      y =

        <class sym>


}

>> S.x
error: cell cannot be indexed with .
>> S.y
error: cell cannot be indexed with .
>>

But with Matlab 2024b I can get the corret behavior

>> syms x y z a
>> eqna = x + y + z == 0
 
eqna =
 
x + y + z == 0
 
>> eqnb = 2*x*y-4==0
 
eqnb =
 
2*x*y - 4 == 0
 
>> S = solve(eqna,eqnb)

S = 

  struct with fields:

    x: [2×1 sym]
    y: [2×1 sym]

>> S.x
 
ans =
 
  (z^2 - 8)^(1/2)/2 - z/2
- z/2 - (z^2 - 8)^(1/2)/2
 
>> S.y
 
ans =
 
- z/2 - (z^2 - 8)^(1/2)/2
  (z^2 - 8)^(1/2)/2 - z/2
 
>> 

Thank you for your attention

Regards

Max

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions