How can i change struct size

조회 수: 75 (최근 30일)
Catarina
Catarina 2023년 1월 17일
댓글: Catarina 2023년 1월 17일
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
  댓글 수: 1
Catarina
Catarina 2023년 1월 17일
Thank you! Works just fine!

댓글을 달려면 로그인하십시오.

추가 답변 (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