Change Names like a Value
1 次查看(过去 30 天)
显示 更早的评论
Hey guys,
how can i change the name of a value automatically? Here is a example:
Year = 1995;
Saison1995 = [1 2 3 4 ];
I would like to change only the value of "Year" and then the name of "SaisonYX" should be adjusted automatically.
Thank you!
回答(1 个)
Image Analyst
2023-1-7
Horrible idea. DON'T do it. Why not? See
and the FAQ:
Not only is it a bad idea, it's unnecessary.
I'm not sure how you want to use the original and new named variables but you should just use a single, constant name, or if you need to keep several versions, use an array
numYears = 10; % 10 possible years.
Saison = zeros(numYears, 4); % 4 by 10 array
Year = 1995;
Saison(1, :) = [1 2 3 4 ]; % Store initial data in row 1.
Year = 2020; % Change year.
Saison(2, :) = [5, 6, 7, 8]; % Store new data in a new row.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!