Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Structures in matlab

Status
Not open for further replies.

Grunde

Computer
Joined
Jul 12, 2011
Messages
6
Location
NO
I've got a question.

I'm translating some old stuff from fortran to matlab, with a bungload of different two or three letter variables. Now, in the first round I found that ordering the variables I use into one big nested structure was awesome, it became very easy to backtrack and refind the origins of every entry.

Now it is too big to maneuver efficiently, however, and I want to write a short function to print it for me.

I am thinking a recursive function, represented in pseudocode below.

function ret = reading_structure (Struc)
x = _the number of terms in the structure_;
for i = 1:x
print(_structure term i_, lineshift);
if _structure term i_= type(struct)
reading_structure(_structure term i_);
end
end
ret = 0;
end


Only problem is to find the number of terms in a structure and to identify a term as a structure. I have searched a bit for it, but i haven't found anyone with a similar problem. If anyone knows how to solve this problem, I'd greatly appreciate it!
 
There it is! Thanks! =D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top