How can i change struct size

66 ビュー (過去 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 Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by