Looping through Cell array

4 ビュー (過去 30 日間)
Syed Abbas
Syed Abbas 2012 年 3 月 26 日
Hi,
I have a cell array of symbols: sym = {'A','B','C'}. I have a function that takes in a symbol (say 'A') and produces a certain result. Right now I am manually feeding in the symbol nmaes to the function. Is there a way to loop through the items of the sym cell array and programatically feed in the symbol names to the function? Thanks

採用された回答

Stephen
Stephen 2012 年 3 月 26 日
Yes, look up eval() and evalin() functions in the help files. These functions accept strings as inputs and evaluate them as though they were entered on the command line. You may also consider using function handles in the cell array instead of strings if you are changing the function regularly.
Stephen
  1 件のコメント
Syed Abbas
Syed Abbas 2012 年 3 月 26 日
thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by