0
votes

I am trying to load a folder path on mac to a folder of MATLAB data sets.

This is the code I am using:

folder_path = '/Documents/2020/Root Locus/Data';

files = dir(fullfile(folder_path,'*.mat'))

The file I am running the code from is located in the root locus folder. My files variable keeps appearing empty as nothing has loaded to it, any help?

1
the command is correct but probably your path not. Are you sure that you folder is reachable from your Current Folder like this (note that it the script/function where you use this command does not necessarily need to be in your Current Folder but may just lie on your path, which may mix up your relative path, from which your want to load - max

1 Answers

0
votes

You need to write the path as either the relative path from Matlab's current folder or the absolute path for the system. An absolute path will start with / and specify the location from the topmost system directory. Relative paths do not start with /.

If you are running Matlab from Root Locus, then try folder_path = 'Data';

The absolute path makes the code more portable, so also try folder_path = '/Users/<username>/Documents/2020/Root Locus/Data';