using math operation as string in array on an expression

1 次查看(过去 30 天)
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?

采纳的回答

Mischa Kim
Mischa Kim 2014-5-23
编辑:Mischa Kim 2014-5-23
yonatan, you are on the right track:
carray = {'3+4','3/4'};
res = eval(carray{2})
res =
0.750000000000000

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by