Effacer les filtres
Effacer les filtres

Symbol results instead of matrix

2 vues (au cours des 30 derniers jours)
Mahmoud Solomon
Mahmoud Solomon le 6 Avr 2018
HI everyone
I have a loop and anticipate to get a sym or equation at the end but I am having a matrix. My question is how can I convert this matrix to symbols so that I can easily evaluate it.
X = [-0.8078;-0.0003;0.0002;1.0035];
x = [x1;x2;x3;x4];
[m,n]=size(x);
for i=1:n-1
aa = x(i).^vpa(X(i+1,1))
end
This is the result.
aa =[1/x1^3.568e-5, x2^7.104e^-6,x3^1.003]
But I would loved it this way
aa =[1/x1^3.568e-5 * x2^7.104e^-6*x3^1.003]

Réponse acceptée

Walter Roberson
Walter Roberson le 6 Avr 2018
You are overwriting all of aa each time through the loop.
Perhaps you should initialize
aa = sym(1);
and then in the loop,
aa = aa * x(i).^vpa(X(i+1,1));
  1 commentaire
Mahmoud Solomon
Mahmoud Solomon le 6 Avr 2018
Thanks. It worked.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements 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