Change Names like a Value
1 view (last 30 days)
Show older comments
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!
Answers (1)
Image Analyst
on 7 Jan 2023
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 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!