Display results in one matrix (nested for loops
1 view (last 30 days)
Show older comments
Mihnea
on 14 Apr 2014
Commented: Vasilis Mitropoulos
on 29 Sep 2019
Hello,
I am working on my final year project, a script that detects moods/emotions generated by audio files. I am currently stuck here:
for i=1:2
for j=4:10
for k=2:3
for l=1:2
for m=1:2
X=(i,j,k,l,m);
End, end, etc.
The reason for this is that each element i,j,k,l,m of the array has several values (i.e. i is 1 or 2, j is 4 through 10 etc.)
Now the problem: I get each possible array in a single line, is there any way to store all of them in a single matrix?
Thank you in advance!
M.
2 Comments
Salaheddin Hosseinzadeh
on 14 Apr 2014
I guess it's
X(i,j,k,l,m)=someting
it won't be a bad idea to correct your code.
You said you want it all in one matrix! Well, they are in one matrix as far as I understand! X is a matrix and apparently that's where you wanna save different values!
Your question is vague!
Accepted Answer
Mischa Kim
on 14 Apr 2014
Edited: Mischa Kim
on 14 Apr 2014
Mihnea, you probably want
X(i,j,k,l,m) = ...
For large matrices you might want to pre-allocate memory:
X = zeros(2,10,3,2,2);
6 Comments
Vasilis Mitropoulos
on 29 Sep 2019
Thanks Mischa Kim, so simply and beautifully resolved what I wanted:)
Have a beautiful day!!!!!!!!!
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!