How to enter characters in cell array ?

5 ビュー (過去 30 日間)
TEEH
TEEH 2016 年 5 月 29 日
コメント済み: TEEH 2016 年 5 月 29 日
I would like to create a cell array with the following output
A = a_1 a_2 a_3 a_4 ....... a_99
I am trying to use the loop method but it's not working. Can anyone help?
A=[];
for i= 1:99
A = [A, 'a_i']
end

採用された回答

Walter Roberson
Walter Roberson 2016 年 5 月 29 日
A={}; for i= 1:99 A = [A, sprintf('a_%d', i)]; end
  1 件のコメント
TEEH
TEEH 2016 年 5 月 29 日
I have made a 3 D matrix. But i need to give each element of this matrix a name so that it can be inserted in the cell array as I need to SET UP a Linear Program .

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 5 月 29 日
A=sprintf('a_%d',1:99)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by