# problem with subs function

33 vues (au cours des 30 derniers jours)
Robert le 30 Nov 2016
Commenté : Walter Roberson le 3 Fév 2021
I use this command daily and sometimes it works and sometimes i get an error.
I am obviously not understanding the complexity of such a simple function
I have a simple symbolic function with two variables. I want to replace one of the variables with a numeric value. What is the issue here.
I have done this countless times with no problem now today its throwing a fit. of course s and k are already declared symbolic other wise open loop would not exists
openloop =
((10*s + 14)*(s + 10))/((10*k*s + s*(s + 1)*(s + 10))*(s + 5))
>> feedforward = subs(openloop,k,11.1)
Error using sym/subs>normalize (line 206) The sizes of the second and third arguments are inconsistent.
Error in sym/subs>mupadsubs (line 137) [X2,Y2,symX,symY] = normalize(X,Y); %#ok
Error in sym/subs (line 125) G = mupadsubs(F,X,Y);
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Walter Roberson le 3 Fév 2021
of course s and k are already declared symbolic other wise open loop would not exists
Well, they were symbolic at the time that openloop was created, but they might not be symbolic now, or might have a different size.

Connectez-vous pour commenter.

### Réponses (4)

Tamir Suliman le 1 Déc 2016
try to add syms s and syms k then run the strings
or syms s k
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

bio lim le 1 Déc 2016
I don't see any problems.
syms s k
openloop = ((10*s + 14)*(s + 10))/((10*k*s + s*(s + 1)*(s + 10))*(s + 5));
feedforward = subs(openloop,k,11.1);
The output is:
feedforward =
((10*s + 14)*(s + 10))/((111*s + s*(s + 1)*(s + 10))*(s + 5))
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

Walter Roberson le 1 Déc 2016
Is your k possibly a vector of symbols? If so then
feedforward = subs(openloop,k,11.1)
would need one replacement value for each variable in k
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Karan Gill le 1 Déc 2016
This is probably it. @Robert, did you read the error message?

Connectez-vous pour commenter.

Jes Bel le 13 Juil 2018
After doing " syms s k " I copy pasted your code and worked fine for me.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Conversion Between Symbolic and Numeric dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by