Borrar filtros
Borrar filtros

using math operation as string in array on an expression

1 visualización (últimos 30 días)
yonatan gerufi
yonatan gerufi el 23 de Mayo de 2014
Editada: Mischa Kim el 23 de Mayo de 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?

Respuesta aceptada

Mischa Kim
Mischa Kim el 23 de Mayo de 2014
Editada: Mischa Kim el 23 de Mayo de 2014
yonatan, you are on the right track:
carray = {'3+4','3/4'};
res = eval(carray{2})
res =
0.750000000000000

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by