Skip to content

How to define a long symbolic vector using for loop with Symbolics.jl #767

@xiang-yu

Description

@xiang-yu

How to define a symbolic vector using for loop with Symbolics.jl?
For example, x=[x1, x2, x3, x4, …, x100], where xi are all variables defined using @variables.
It can be easily done using sympy.jl as
julia> N=100, x = [symbols(“x$i”) for i in 1:N].

For short vector, x = @variables x1, x2, x3 work. However for, 100 or even 1000 long vectors, a for loop would be useful.

Please note that I must use Symbolics.jl for the sake of speed and complicated matrix manipulation.
I am aware of the symbolic arrays introduced at Symbolic arrays · Symbolics.jl 1,
but it does not work for my purpose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions