How can i change struct size

80 visualizaciones (últimos 30 días)
Catarina
Catarina el 17 de En. de 2023
Comentada: Catarina el 17 de En. de 2023
Hi, I currently have one struct variable that includes another structure with dimensions 1x64, that itself contains three different fields (X,Y,Z). Each one of these fields has 64 numbers (hence, three columns with 64 lines each). However, I want to eliminate lines 49 to 64 because I only need the first 48 lines for each field. Overall what I pretend is to resize this 1x64 structure to a 1x48 one.
How can I do this? The only solution i found was to replace their value by "[]" which is not quite what im looking for.
Thank you in advance!
  2 comentarios
Stephen23
Stephen23 el 17 de En. de 2023
Save your data in a MAT file and upload it here by clicking the paperclip button.
Catarina
Catarina el 17 de En. de 2023
here it is. its the "locations" structure i want to resize

Iniciar sesión para comentar.

Respuesta aceptada

Stephen23
Stephen23 el 17 de En. de 2023
Movida: Stephen23 el 17 de En. de 2023
S = load('sample_data.mat')
S = struct with fields:
ECOG: [1×1 struct]
E = S.ECOG
E = struct with fields:
name: 'ECoG-Seizure-64-Channels' type: 'ECOG' nbchan: 64 points: 2000 srate: 400 labeltype: '' labels: {1×64 cell} locations: [1×64 struct] data: [64×2000 double] unit: 'mv' start: 1 end: 1 dispchans: 1 bad: [57 58 59 60 61] vidx: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 62 63 64] min: -22.1477 max: 22.1602 size: [8 8]
E.locations
ans = 1×64 struct array with fields:
X Y Z
E.locations(49:end) = [] % remove those structure elements
E = struct with fields:
name: 'ECoG-Seizure-64-Channels' type: 'ECOG' nbchan: 64 points: 2000 srate: 400 labeltype: '' labels: {1×64 cell} locations: [1×48 struct] data: [64×2000 double] unit: 'mv' start: 1 end: 1 dispchans: 1 bad: [57 58 59 60 61] vidx: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 62 63 64] min: -22.1477 max: 22.1602 size: [8 8]
E.locations
ans = 1×48 struct array with fields:
X Y Z

Más respuestas (0)

Categorías

Más información sobre Structures en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by