Defining a variable based on input

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'?

 Respuesta aceptada

Amit
Amit el 30 de En. de 2014
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 comentarios

Azzi Abdelmalek
Azzi Abdelmalek el 30 de En. de 2014
This is a very bad idea to create several variables. Just use a cell array to store all your matrices
Conor
Conor el 30 de En. de 2014
Thanks for the suggestions. I decided to use a 3-D array.
Amit
Amit el 30 de En. de 2014
Good choice!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Operators and Elementary Operations en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 30 de En. de 2014

Comentada:

el 30 de En. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by