Problems with nested indexing

Hello,
I'm using a MATLAB algorithm to project and size the components of a vehicular suspension system.
In the following lines, an error is happening:
syms a2 b2
eq3=a2*Xmse+b2-Ymse;
eq4=a2*Xes+b2-Yes;
S2=solve(eq3,eq4);
a2=S2.a2(1);
b2=S2.b2(1);
OBS: the variables Xmse, Ymse, Xes and Yes are all real numbers.
This is the error that is happening every time I run the algorithm:
" Error using sym/subsref (line 747)
SYM objects do not allow nested indexing. Assign intermediate values to variables instead.
Error in projeto_de_suspensao (line 136)
a2=S2.a2(1); "
I don't know how to fix it. Can you help me?
Thanks for the support

2 comentarios

Walter Roberson
Walter Roberson el 23 de Mzo. de 2019
Which MATLAB release are you using? I do not get that error.
The message you are getting is what you would get if the result of the solve() were a single symbolic expression rather than a structure of results. You would get a single result if eq4 somehow ended up being a scalar symbolic variable name
ROBSON SCHNEIDER
ROBSON SCHNEIDER el 27 de Mzo. de 2019
MATLAB Release R2015a, Version 8.5.0.197613

Iniciar sesión para comentar.

Respuestas (1)

madhan ravi
madhan ravi el 14 de Mzo. de 2019
Editada: madhan ravi el 23 de Mzo. de 2019

0 votos

Remove (1) from the last two lines.

1 comentario

madhan ravi
madhan ravi el 14 de Mzo. de 2019
Editada: madhan ravi el 14 de Mzo. de 2019
Alternative:
[a2,b2]=solve(eq3,eq4,[a2,b2])

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Preguntada:

el 14 de Mzo. de 2019

Comentada:

el 27 de Mzo. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by