How can i get rows in a multidimensional array to be a new array?
4 views (last 30 days)
Show older comments
Hi.
I dealing with a multidimensional array, and is a bit lost. From my multidimensional array below, i want each row to become a own array. So in my case I wish to have 9 arrays, each with dimension 1X4. So that my first array is
16.7938 0.6839 0.3873 0.2771
second is
0 0 0 0
and so on...
I was trying somthing like Gx(m,:,:), but ended up with 3rd row from each page.
Iam getting my array from these for-loops:
for j=1:Q
for m=1:N
for n=1:N
Gx(m,j,n)=Gu(n,m,j);
end
end
end
where Q=4 and N=3
Gx
Gx(:,:,1) =
16.7938 0.6839 0.3873 0.2771
0 0 0 0
0 0 0 0
Gx(:,:,2) =
16.4220 0.0000 0.0000 0.0000
3.5144 0.6839 0.3873 0.2771
0 0 0 0
Gx(:,:,3) =
16.0584 0.0000 0.0000 0.0000
3.4366 0.0000 0.0000 0.0000
3.5144 0.6839 0.3873 0.2771
Later iam going to change values for N and Q, so i wish to express my code in a generalized way. With j,m,n if possible.
Any suggestions?
0 Comments
Accepted Answer
Sean de Wolski
on 17 Apr 2013
Why do you want this? It's much easier to just index into your multidimensional array than to have many arrays. Think about how this scales: do you want 1000 separate arrays?
0 Comments
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!