Passing field name into function

Jun 2010
For some reason, when I try to use this function it has a problem passing along the field name input.
For example, I'd type something like :

Field(S, 'names')


This returns an error:

??? Reference to non-existent field 'fname'.

Error in ==> CheckFieldConsistency at 4
[m n] = size(Q(1).fname);


function output = Field(Q, fname)

k = 0;
[m n] = size(Q(1).fname);
dim = [m n];

Can someone please enlighten me on how I would go about passing this string along into the function to be utilized?

Thank you for your time.