How to load a .mat file from a URL
16 views (last 30 days)
Show older comments
I find that I cannot load a .mat file from a URL. For example, when I try to call load() with the full URL of the attached .mat file as input, I obtain,
load('https://www.mathworks.com/matlabcentral/answers/uploaded_files/414803/tst.mat')
I have no such difficulty using imread() to read in image files from Answers URLs. Why does load() behave differently, and is there a workaround?
0 Comments
Accepted Answer
Ameer Hamza
on 15 Nov 2020
Edited: Ameer Hamza
on 15 Nov 2020
imread() documentation mentions support for URL, but load documentation does not say anything about it. I think the closest possible thing is something like this.
load(websave('myFile', 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/414803/tst.mat'))
4 Comments
the cyclist
on 25 May 2021
Agreed that this is amazing functionality.
% load('tst.mat') % Commented so that this example doesn't run.
works for OP if they are the one who uploaded the file in their question. For example, I uploaded the file x.mat along with this comment, and I have access to it directly:
load('x.mat')
disp(x)
the cyclist
on 25 May 2021
Note that I cannot access x.mat in this followup comment:
load('x.mat')
disp(x)
but I could use your websave trick.
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!