Dynamic variables matlab

2019-01-28 19:32发布

How can I access to dynamic variables in Matlab? I search for similar question but I didn't find.

Example (simplified):

for i=1:1
    aux3=(i-1)*50;

    delay_64_264(1,i) = mean(delay_64_264_', num2str(aux3), ' (:,3)*100;

end

What I want to do is mean of column 3 from variable delay_64_264_0.

Anyone can help me?

Thank you very much

标签: matlab eval
2条回答
smile是对你的礼貌
2楼-- · 2019-01-28 20:15

You can use eval().

But I recommend not doing this at all. Use a multidimensional array, rather than lots of variables with slightly different names.

查看更多
你好瞎i
3楼-- · 2019-01-28 20:24

To follow on from Oli's suggestions, see this piece of the MATLAB FAQ:

http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F

which shows how to use structures and cell arrays as an alternative to eval.

查看更多
登录 后发表回答