I am using:
angle=regexp(folder(i).name,'\d+','match');
To get a numerical value out of the folder name.
It returns the value in the cell " angle ". I'd like to multiply this value by a scalar 3.14/180 and then use it in a function call: function(angle*3.14/180,...)
I've attempted some work with cellfun ( following this thread: http://www.mathworks.com/matlabcentral/answers/115522-multiply-a-cell-array-with-a-scalar), no success so far.
Is there a better way to approach this?
Thank you

 採用された回答

Adam
Adam 2014 年 9 月 23 日
編集済み: Adam 2014 年 9 月 23 日

1 投票

angle = str2double( angle{1} ) * 3.14/180;
will put your value in a regular double assuming that you only have 1 cell or that the angle you want is in the first cell and that the result of regexp is actually a string containing the number as it would appear to be. If not, just get rid of the str2num.

2 件のコメント

Andrew
Andrew 2014 年 9 月 23 日
Thank you very much :D
Adam
Adam 2014 年 9 月 23 日
編集済み: Adam 2014 年 9 月 23 日
Actually, I just remembered, str2double is the recommended function to use now, but str2num does still work, it's just less efficient I think. I edited the answer to reflect that.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Types についてさらに検索

質問済み:

2014 年 9 月 23 日

編集済み:

2014 年 9 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by