How can i get rows in a multidimensional array to be a new array?

3 次查看(过去 30 天)
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?

采纳的回答

Sean de Wolski
Sean de Wolski 2013-4-17
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 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by