Create Matrix using loop

1 Ansicht (letzte 30 Tage)
Sydney Lavan
Sydney Lavan am 7 Apr. 2020
Kommentiert: Sydney Lavan am 7 Apr. 2020
I have a data file containing 2,239,488 values. I need to arrange these values in a 108*108*192 matrix. The data file is arranged in such matter (0,0,0),(1,0,0),(2,0,0)....(107,0,0),(0,1,0),(2,1,0)...(107,1,0),(0,2,0),(1,2,0).......(107,107,191). i.e. my x coordinates runs fasters (inner loop) and the y in the middle loop and finally z is the outer loop until Ive exhausted the 108*108*192 numbers.
Is there a function or code to take my data file and arrange in such matrix?
Thanks, Sydney

Akzeptierte Antwort

David Hill
David Hill am 7 Apr. 2020
Look at reshape() function.
reshape(yourMatrix,108,108,192);
  5 Kommentare
David Hill
David Hill am 7 Apr. 2020
A=yourMatrix;
A=A(:);
A=A(A~=0);
B=reshape(A,108,108,192);
Sydney Lavan
Sydney Lavan am 7 Apr. 2020
Great this worked !
Thank you, Sydney

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by