フィルターのクリア

using math operation as string in array on an expression

1 回表示 (過去 30 日間)
yonatan gerufi
yonatan gerufi 2014 年 5 月 23 日
編集済み: Mischa Kim 2014 年 5 月 23 日
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 Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by