Create a variable from string

108 次查看(过去 30 天)
Hello!
In my Matlab program, I have a class named "time". In this class I have a variable named "car". in a FOR loop, I am adding coefficients to this variable which gives me "car1", "car2", "car3". But I want these variables to remain in the "time" class.
How can I do it? I used to have something like this before creating the "time" class:
assignin('base', ['car' num2str(count+1)], somevalue);
This would give me the variables "car1", "car2", and so on, depending on the "count" variable. But how can I make the "time.car1", "time.car2", "time.car3" variables? ASSIGNIN doesn't accept classes in the variable name.
Thanks in advance!

采纳的回答

Stephen23
Stephen23 2015-9-1
编辑:Stephen23 2019-6-19

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by