Effacer les filtres
Effacer les filtres

using math operation as string in array on an expression

1 vue (au cours des 30 derniers jours)
yonatan gerufi
yonatan gerufi le 23 Mai 2014
Modifié(e) : Mischa Kim le 23 Mai 2014
Hi all,
i need to do some math operation on elements in certain order, as:
3+4, 3-4, 3*4, 3/4, 3^4
i thought using a string array
['+','-','*'..]
and somehow to do
3 arr[i] 4
but i just can't make it work! any ideas?

Réponse acceptée

Mischa Kim
Mischa Kim le 23 Mai 2014
Modifié(e) : Mischa Kim le 23 Mai 2014
yonatan, you are on the right track:
carray = {'3+4','3/4'};
res = eval(carray{2})
res =
0.750000000000000

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings 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