Know the number of row within a structure (struct)

29 views (last 30 days)
Hi! I have the following 'CODE' struct.
I would like to know if there is a code to determine the row number (present in 'Fields', for example 7) considering this as input:
folder = 'C:\Users\Alberto\Desktop\GLOBAL\DATA 4'
Alberto Acri
Alberto Acri on 10 Nov 2022
Edited: Alberto Acri on 10 Nov 2022
@Stephen23 Yes, I know! I wanted to determine element 7 of struct CODE in correspondence of 'name' 'a'.
But the same is true for example at element 1,4,10 of struct CODE at 'name' 'a' where 'DATE 1', 'DATE 11' and 'DATE 6' are given respectively.

Sign in to comment.

Accepted Answer

Joseph Cheng
Joseph Cheng on 10 Nov 2022
so you can use the function find() and contains(). in this example i am just searching the name entry but it should work with your folder instead.
abc = 'a'-1;
for ind = 1:10
CODE(ind).name = char(abc+ind);
foundRow = find(contains({},'d'))
foundRow = 4
Where by doing {} here it'll make each entry into a cell then find which one contains your desired text.

Sign in to comment.

More Answers (0)


Find more on Structures in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by