Effacer les filtres
Effacer les filtres

Change Names like a Value

1 vue (au cours des 30 derniers jours)
Max1234
Max1234 le 7 Jan 2023
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!

Réponses (1)

Image Analyst
Image Analyst le 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.

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by