필터 지우기
필터 지우기

Change Names like a Value

조회 수: 1 (최근 30일)
Max1234
Max1234 2023년 1월 7일
답변: Image Analyst 2023년 1월 7일
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
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.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by