create different vector using for loop

2 ビュー (過去 30 日間)
MUKESH KUMAR
MUKESH KUMAR 2017 年 8 月 1 日
回答済み: Jan 2017 年 8 月 1 日
I have three users named A1, A2 and A3 and each user has three appliances like A11 represent the A1's 1st appliance and A12, A13 similarly A21, A22, A23, and A31, A32, A33. I have the following matrix A11=[1 1 1 1 2]; A12=[1 2 2 2 2]; ......so on. so how can i use for loop for excessing these vectors and if these data in excel then how can we excess?
  2 件のコメント
KSSV
KSSV 2017 年 8 月 1 日
What is this A11=[1 1 1 1 2]; ?
Stephen23
Stephen23 2017 年 8 月 1 日
Do NOT waste your time writing bad code that creates separate variables with numbered variable names: "A frequent use of the eval function is to create sets of variables such as A1, A2, ..., An, but this approach does not use the array processing power of MATLAB and is not recommended."
Just use indexing: simple, fast, efficient, neat, simple, easy to understand, much less buggy, easier to debug, etc, etc, etc.
etc, etc, etc.

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

回答 (1 件)

Jan
Jan 2017 年 8 月 1 日
Don't do this. The question is asked several times each week, and the answer is always the same. Do not hide an index in the name of a variable. Use an index instead.
Avoid functions such as eval, evalc, evalin, and feval(fname). Use the function
handle input to feval whenever possible. Indirectly evaluating a MATLAB expression
from text is computationally expensive.

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by