Defining a variable based on input

2 ビュー (過去 30 日間)
Conor
Conor 2014 年 1 月 30 日
コメント済み: Amit 2014 年 1 月 30 日
I am trying to create a set of variables based on input.
For example, I have the matrix
angle=[30,45,60]
I do some calculations using each angle and I want to put the results into individual matrices for each angle. I want each matrix to be named partially using the respective input angle. The number of inputs in angle(:) and their values are arbitrary.
For example, the first matrix would be named Qbar30, the second Qbar45, and the third Qbar60. Is there a way to declare variables with an input and a preceding string like 'Qbar'?

採用された回答

Amit
Amit 2014 年 1 月 30 日
If that is what you want, try eval
doc eval
However, you can skip making each variable with a new name and try cell or structure.
  4 件のコメント
Conor
Conor 2014 年 1 月 30 日
Thanks for the suggestions. I decided to use a 3-D array.
Amit
Amit 2014 年 1 月 30 日
Good choice!

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

その他の回答 (0 件)

カテゴリ

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