How can i change struct size

66 次查看(过去 30 天)
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 个评论
Stephen23
Stephen23 2023-1-17
Save your data in a MAT file and upload it here by clicking the paperclip button.
Catarina
Catarina 2023-1-17
here it is. its the "locations" structure i want to resize

请先登录,再进行评论。

采纳的回答

Stephen23
Stephen23 2023-1-17
移动:Stephen23 2023-1-17
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

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by