3

I have several 100 *.mat files with matrices with same shapes. But over time this matrices were saved with different names. Lets say for this example a or b.

How can I now load and process this data without knowing the name using a new name instead?

An if condition is not an option, because there are too many different names.

I already tryed:

data = load('example_file.mat')

but then I need again the old variable names to access the matrices with data.a or data.b ...

What I need is something like:

load('example_file.mat') as matrix

Is this possible in Octave?

1 Answer 1

4

Your attempt

data = load('example_file.mat')

is the right start. You can examine data to find out what variables it contains. Assuming there’s always a single matrix in the MAT-file,

names = fieldnames(data);
data = data.(names{1});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.