19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Simon Schirk vor etwa 20 Stunden
-
-
Verknüpfen
Direkter Link zu dieser Frage
https://de.mathworks.com/matlabcentral/answers/2108586-how-to-extract-data-from-a-3d-array
⋮
-
-
Verknüpfen
Direkter Link zu dieser Frage
https://de.mathworks.com/matlabcentral/answers/2108586-how-to-extract-data-from-a-3d-array
Beantwortet: Dyuman Joshi vor etwa 12 Stunden
I have a large (500x5x79039) 3D array, which is mostly filled with zeros. Now I want to extract the slices with content into a smaller array and save them. I’ve already tried the solution from this Article, but then I get the same page repeated multiple times, resulting in too many entries and duplicates.
Ideally, I would like to extract the pages exactly as they were saved, provided there is data on those pages.
4 Kommentare 2 ältere Kommentare anzeigen2 ältere Kommentare ausblenden
2 ältere Kommentare anzeigen2 ältere Kommentare ausblenden
Jonas vor etwa 14 Stunden
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/2108586-how-to-extract-data-from-a-3d-array#comment_3135971
⋮
- Verknüpfen
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/2108586-how-to-extract-data-from-a-3d-array#comment_3135971
See AlsoCompare Ways to Export Graphics from Figures - MATLAB & Simulink - MathWorks América LatinaSave Figure with Specific Size, Resolution, or Background Color - MATLAB & SimulinkHow do I extract data from MATLAB figures?Save Plot as Image or Vector Graphics File - MATLAB & Simulink - MathWorks Deutschland
so a slice is a 2d matrix for me, into which direction do you want to slice? if i understood correctly, you only want those 2d slices, in whch at least one entry is not zero?
Simon Schirk vor etwa 12 Stunden
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/2108586-how-to-extract-data-from-a-3d-array#comment_3136111
⋮
- Verknüpfen
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/2108586-how-to-extract-data-from-a-3d-array#comment_3136111
Yes, exactly.
Harald vor etwa 12 Stunden
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/2108586-how-to-extract-data-from-a-3d-array#comment_3136151
⋮
- Verknüpfen
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/2108586-how-to-extract-data-from-a-3d-array#comment_3136151
Jonas inquired about the direction of indexing. In other words, you can get
a) a n x 5 x 79039 array with n < 500
b) a 500 x n x 79039 array with n < 5
c) a 500 x 5 x n array with n < 79039
Each can be done, but it would be great to know which of the three you are looking for.
Simon Schirk vor etwa 12 Stunden
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/2108586-how-to-extract-data-from-a-3d-array#comment_3136211
⋮
- Verknüpfen
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/2108586-how-to-extract-data-from-a-3d-array#comment_3136211
Sorry, my bad. I'm looking for c). The Data I'm looking for should be displayed as 500 x 5 x n, like the pages in my existing array.
Melden Sie sich an, um zu kommentieren.
Melden Sie sich an, um diese Frage zu beantworten.
Antworten (1)
Dyuman Joshi vor etwa 11 Stunden
-
-
Verknüpfen
Direkter Link zu dieser Antwort
https://de.mathworks.com/matlabcentral/answers/2108586-how-to-extract-data-from-a-3d-array#answer_1443956
⋮
-
-
Verknüpfen
Direkter Link zu dieser Antwort
https://de.mathworks.com/matlabcentral/answers/2108586-how-to-extract-data-from-a-3d-array#answer_1443956
Use logical indexing -
%Sample data
p = 5;
q = 6;
r = 4;
y = rand(p,q,r)-1;
y(:, :, [2 r+1]) = zeros(p,q,2)
y =
y(:,:,1) = -0.7285 -0.6881 -0.6747 -0.3796 -0.1672 -0.6574 -0.9762 -0.6068 -0.9793 -0.0795 -0.9972 -0.5266 -0.7477 -0.1073 -0.9397 -0.5630 -0.9243 -0.7642 -0.2448 -0.1465 -0.7908 -0.8282 -0.3473 -0.0134 -0.3137 -0.4403 -0.8926 -0.5689 -0.2770 -0.4045y(:,:,2) = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0y(:,:,3) = -0.0481 -0.3703 -0.8937 -0.2620 -0.6424 -0.1590 -0.3590 -0.7458 -0.8042 -0.6762 -0.5639 -0.4337 -0.4247 -0.3759 -0.6399 -0.7271 -0.9687 -0.0107 -0.3895 -0.5470 -0.2762 -0.8224 -0.4897 -0.7164 -0.5377 -0.7156 -0.8387 -0.6348 -0.3393 -0.1025y(:,:,4) = -0.7409 -0.3158 -0.9468 -0.7263 -0.4370 -0.7029 -0.3200 -0.8704 -0.2631 -0.8824 -0.4113 -0.4293 -0.5657 -0.7926 -0.9319 -0.6440 -0.1914 -0.1186 -0.0940 -0.8801 -0.3449 -0.3131 -0.0717 -0.8211 -0.6848 -0.8336 -0.2107 -0.4389 -0.7302 -0.3056y(:,:,5) = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
%Check if there is any non-zero element in a page
idx = any(y, [1 2])
idx = 1x1x5 logical array
idx(:,:,1) = 1idx(:,:,2) = 0idx(:,:,3) = 1idx(:,:,4) = 1idx(:,:,5) = 0
%Use the (logical) index to get the corresponding data
out = y(:, :, idx)
out =
out(:,:,1) = -0.7285 -0.6881 -0.6747 -0.3796 -0.1672 -0.6574 -0.9762 -0.6068 -0.9793 -0.0795 -0.9972 -0.5266 -0.7477 -0.1073 -0.9397 -0.5630 -0.9243 -0.7642 -0.2448 -0.1465 -0.7908 -0.8282 -0.3473 -0.0134 -0.3137 -0.4403 -0.8926 -0.5689 -0.2770 -0.4045out(:,:,2) = -0.0481 -0.3703 -0.8937 -0.2620 -0.6424 -0.1590 -0.3590 -0.7458 -0.8042 -0.6762 -0.5639 -0.4337 -0.4247 -0.3759 -0.6399 -0.7271 -0.9687 -0.0107 -0.3895 -0.5470 -0.2762 -0.8224 -0.4897 -0.7164 -0.5377 -0.7156 -0.8387 -0.6348 -0.3393 -0.1025out(:,:,3) = -0.7409 -0.3158 -0.9468 -0.7263 -0.4370 -0.7029 -0.3200 -0.8704 -0.2631 -0.8824 -0.4113 -0.4293 -0.5657 -0.7926 -0.9319 -0.6440 -0.1914 -0.1186 -0.0940 -0.8801 -0.3449 -0.3131 -0.0717 -0.8211 -0.6848 -0.8336 -0.2107 -0.4389 -0.7302 -0.3056
0 Kommentare -2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden
-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden
Melden Sie sich an, um zu kommentieren.
Melden Sie sich an, um diese Frage zu beantworten.
Es ist ein Fehler aufgetreten
Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom(English)
Asien-Pazifik
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
Kontakt zu Ihrer lokalen Niederlassung