Symbolic vector problem in MATLAB

1 Ansicht (letzte 30 Tage)
Berke Ogulcan Parlak
Berke Ogulcan Parlak am 8 Dez. 2019
Beantwortet: Walter Roberson am 8 Dez. 2019
Hi, I'm using the 2016a version and syms doesn't work as a vector.
I try:
syms a [1 4]
but I take "Not a valid variable name" error.
I know I can use sym instead:
sym('a', [1,4])
However, my request is not to use like a (1),I want Matlab to recognize it when I type a1.
  1 Kommentar
Star Strider
Star Strider am 8 Dez. 2019
The only way seems to be to actually type:
syms a1 a2 a3
I experimented with str2sym to do this, without success.
You can use sprintf or compose to create a vector of symbolic variables to manually copy and paste to your syms call :
a = compose("a%d", 1:5)
however that appears to be the only way to do what you want.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 8 Dez. 2019
syms(sym('a', [1 4]))

Produkte


Version

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by