Run a loop on struct field

7 ビュー (過去 30 日間)
DavidL88
DavidL88 2020 年 6 月 29 日
編集済み: DavidL88 2020 年 7 月 4 日
Hi
I am running a statistical analysis. I need to run the analysis multiple times for 6 different 'sensortypes'. This data is stored in a 2x1 struct with two fields called S. The data to be inputted is in the secomd field 'ROI_Sig'. Can anyone help with getting the loop to run in the script below?
for i = 1:length(S)
ROIData = S(i).ROI_Sig;
sFiles = bst_process('CallProcess', 'process_test_permutation2', sFiles5 sFiles6, ...
'sensortypes', ROIData, ...
end
  1 件のコメント
DavidL88
DavidL88 2020 年 7 月 1 日
The script runs correctly if I delete the loop and replace i with any value 1-6 in the line ROIData = S(i).ROI_Sig;

サインインしてコメントする。

採用された回答

Neeraj Rajpurohit
Neeraj Rajpurohit 2020 年 6 月 30 日
Hi,
You can use the below mentioned command to get a string array of all the fields in a struct s.
fields = string(fieldnames(s))
Refer to the doc link belowfor more details
  1 件のコメント
DavidL88
DavidL88 2020 年 6 月 30 日
Hi
Thank you for your reply. It is not the fieldname that I want to enter. It is the data within the field. Please see structure below. I want to make a loop to input each of the 6 rows from field ROI_Sig
S =
6×1 struct array with fields:
Region
ROI_Sig
ROI_Sig =
6×1 cell array
{'91, 92, 95, 96, 103'}
{'61, 67, 73, 74' }
{'113, 114' }
{'32, 34' }
{'127' }
{'41' }

サインインしてコメントする。

その他の回答 (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