フィルターのクリア

Is it possible to assign multiple variables to one number?

107 ビュー (過去 30 日間)
Shawn Simon
Shawn Simon 2015 年 11 月 4 日
For example, is there a much more efficient way of doing this:
a = 0;
b = 0;
c = 0;
And so on; essentially, I am trying to set a-z equal to 0. I am just trying to make my script seem less long. Thank you for the help.

採用された回答

Jan
Jan 2015 年 11 月 7 日
If you really have 26 variables with a single charater name 'a' to 'z' which are all scalars, use one vector:
a = zeros(1, 26);
and a(2) instead of b.

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2015 年 11 月 6 日
[a, b, c] = deal(0);
  2 件のコメント
Ale Kat
Ale Kat 2019 年 7 月 21 日
excellent
Pedro Cabrera Santana
Pedro Cabrera Santana 2023 年 6 月 13 日
great answer!

サインインしてコメントする。


Bharath Rangaswamy
Bharath Rangaswamy 2015 年 11 月 6 日
Hi Shawn,
There is no way to assign multiple variables to one number.
Best,
Bharath

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by