how to make a file .mat as a function input and load it inside the function
4 views (last 30 days)
Show older comments
rachida
on 21 Jul 2019
Commented: Walter Roberson
on 21 Jul 2019
Hey everyone
I am developping a function and i need a A.mat as an infile input of the function B , inside the function i hav to do file load , and to say that the function and the A.mat are in the same directory. so the alogorithme would be like thise
function B(filemat)
load filemat
thank you
0 Comments
Accepted Answer
Walter Roberson
on 21 Jul 2019
Edited: Walter Roberson
on 21 Jul 2019
data = load(filemat);
Now the variables you need will each be fieldnames of the struct data
2 Comments
Walter Roberson
on 21 Jul 2019
You were using
load filemat
which is equivalent to
load('filemat')
which ignores the content of the variable named filemat and instead tries to load something literally named filemat.mat
My suggested code uses the content of the variable named filemat to see where it should load
More Answers (0)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!