How to count field numbers of structure?

510 views (last 30 days)
Please let me know how to count field numbers of structure as below.
Structure.A = zeros(10); Structure.B = zeros(10); Structure.C = zeros(10);
there are 3 fields in structure, and I want to know number '3'.
  2 Comments
Vincent Hall
Vincent Hall on 6 Sep 2019
Thanks Stephen Cobeldick, that works nicely.

Sign in to comment.

Accepted Answer

KSSV
KSSV on 16 Oct 2015
length(fieldnames(Structure))
  3 Comments
GyuSang
GyuSang on 16 Oct 2015
Thank you for your answer.
Jan
Jan on 16 Oct 2015
@Jos: I've seen many bugs caused by using length too sloppy. In the current case fieldnames replies a cell vector, such that length is trustworthy here.

Sign in to comment.

More Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!