Grunde
Computer
- Jul 12, 2011
- 6
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!
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!