indexing a variable in matlab

조회 수: 8 (최근 30일)
Rica
Rica 2014년 9월 18일
댓글: Guillaume 2014년 9월 18일
Hi, How could i parametrize a data set in matlab. for exemple:
MeasNr=1
Meas_(MeasNr) to get Meas_1?
thank you
  댓글 수: 1
the cyclist
the cyclist 2014년 9월 18일
Please remember that everything we know about your particular problem comes from what you write in your question. At least for me, there is not enough explanation here for me to understand what you want to do.

댓글을 달려면 로그인하십시오.

채택된 답변

Iain
Iain 2014년 9월 18일
The normal right answer is to just use arrays. This limits you to using normal indexing techniques (logical & positive integer)
MeasNr = 1;
Meas_(MeasNr) = 5;
The "other" right answer is to define a class that stores both index values & result values. This is more work, but allows you to have noninteger indexing
The wrong answer, is to dynamically change variable names. - This should only be used in dire circumstances:
eval(['Meas_' num2str(MeasNr) ' = 5;'])
  댓글 수: 1
Guillaume
Guillaume 2014년 9월 18일
Actually, the 'other' right answer is not particularly more work, it already exists as
containers.Map

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Michael Haderlein
Michael Haderlein 2014년 9월 18일
I read this question as if you want to get variable names such as Meas_1, Meas_2 etc. That's not how you should work in Matlab. More information e.g. http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F

카테고리

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