How to use sprintf in a variable name?

2 ビュー (過去 30 日間)
Sam
Sam 2014 年 12 月 27 日
回答済み: Star Strider 2014 年 12 月 27 日
For example, I want to do this (but it gives an error):
row = 4
col = 2
Duration_Trial(num2str('col'))_pp(num2str('row')) = length(data_stair_rise(row, col).VideoSignals)/data_stair_rise(row, col).VideoFrameRate; % expression after the '=' is not important.
What did I do wrong?

回答 (1 件)

Star Strider
Star Strider 2014 年 12 月 27 日
You don’t need num2str. Just use ‘row’ and ‘col’ as they are:
Duration_Trial(col, _pp(row)) = length(data_stair_rise(row, col).VideoSignals)/data_stair_rise(row, col).VideoFrameRate;
I cannot follow what you are doing, but that change should at least get you closer to what you want.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by