How can I assign the values of multiple variables in one line using vector notation?

조회 수: 18 (최근 30일)
Given two variables 'var1' and 'var2', the goal is to assign these variable to values 1 and 2 in one line using vector notation.
How can this be done?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2020년 9월 3일
This can be done using the function 'deal', which for the particular example would look as follows,
>> [var1, var2] = deal(1, 2)
var1 =
1
var2 =
2
For more information visit the corresponding documentation page for function 'deal',
  댓글 수: 1
madhan ravi
madhan ravi 2020년 9월 3일
편집: madhan ravi 2020년 9월 3일
From the original question it looked like the values where char until looking into the answer. But nevertheless it’s a popular function indeed.

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

추가 답변 (0개)

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by