How to name Array with each of my Arrays in a bulk folder?

1 Ansicht (letzte 30 Tage)
Jeremy Choo
Jeremy Choo am 28 Sep. 2021
Beantwortet: Ravi Narasimhan am 28 Sep. 2021
This is a simple problem yet I can't seem to solve it. I have a set of arrays in a file called 'results'. There are 8 in total, so far I want to separate all of them, to get Array1 = results{1,1}, Array2 = results{2,1}, etc. However, i can't seem to create a for loop that does this. I've tried i=1:length(results), which should give me i=1:8, but hw do i incorporate that into my Array name? Array(i) gives me the porperties of the array instead, which I do not want. Is there a simple way to get Arrayn = results{n,1}?

Antworten (2)

Jan
Jan am 28 Sep. 2021
Bearbeitet: Jan am 28 Sep. 2021
Do not hide an index in the name of variables. Although it is piossible to do this using the eval command, it increases the complexity of the code without any benefit, and impedes the processing such that the code can need up to 100 times more tome to be executed.
result{n} is ways better than Array1, Array2, ...

Ravi Narasimhan
Ravi Narasimhan am 28 Sep. 2021
I believe what you are requesting (dynamically naming variables) can be done but is strongly discouraged. Here is a reference for why and how to achieve equivalent results in different ways. There are multiple links within that main one that are worth the time.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by