MATLAB Troubleshooting: Passing String Inputs in Matlab's Structure Field Function

  • Thread starter Thread starter darthxepher
  • Start date Start date
  • Tags Tags
    Field Structure
AI Thread Summary
The discussion centers on an issue with passing a string input to a function in MATLAB, specifically when trying to access a structure field. The user encounters an error indicating a reference to a non-existent field 'fname' when executing the function Field(S, 'names'). The error arises during the attempt to determine the size of the field using the expression [m n] = size(Q(1).fname). The user seeks guidance on how to properly pass the string input so it can be utilized within the function. Clarification on this issue is requested, highlighting a need for assistance in resolving the problem.
darthxepher
Messages
56
Reaction score
0
For some reason, when I try to use this function it has a problem passing along the fname 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.
 
Physics news on Phys.org
Does no one really know?
 
Back
Top