Shortcut to making an array

9 visualizaciones (últimos 30 días)
Sarah Abdullah
Sarah Abdullah el 3 de Abr. de 2020
Comentada: Stephen23 el 3 de Abr. de 2020
Hi,
I have 41 variable named b1 through 41 (ex. b1 b2 b3 b4...), I'm trying to combine all these varibale into one array. But I want to see if there is a shortcut to do so.
I know I can do K= [b1 b2 ... b41], but I'm wondering if there is a shortcut to that.
Thank you
  1 comentario
Stephen23
Stephen23 el 3 de Abr. de 2020
Numbered variables are a sign that you are doing something wrong.
Most likely those names were generated in a loop or when importing data (unless you sat there and wrote out all of those names), in which case that is the correct place to fix your code. For example, rather than load-ing directly into the workspace, load into an output variable (which is a scalar structure) and then access it from that variable:
S = load(...)

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 3 de Abr. de 2020
The shortcut is to not create those as separate variables the first time around.

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by