Filter löschen
Filter löschen

Change Names like a Value

2 Ansichten (letzte 30 Tage)
Max1234
Max1234 am 7 Jan. 2023
Beantwortet: Image Analyst am 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!

Antworten (1)

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

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by