MATLAB: Transferring .mat files to workspace mat plotMATLABMATLAB and Simulink Student Suite Hi, I need a help with 1 question. I have 400 .mat files(Scope_Data). I must transfer them all to workspace. Can someone help Me? Best Answer Use dir Function To Loop Through All The Files And Load ThemfileList = dir('Your_path_goes_here');data = cell();for fi = length(fileList):-1:1 file = fileList(fi); if file.isdir continue; end data{fi} = load(fullfile(file.folder, file.name));endNow You Can Do Whatever You Want With The Data.*If All Files Contain The same Varriables, You Can Load It Into Struct Array Instead Of Cell Array, And It Would Be More Convenient To Work With Related SolutionsMATLAB: Load .mat file from anyfolder load C:\myFolder\mySubFolder\myMatFile.matorvariableName= 'myVarName';matfilePath = 'C:\myFolder\mySubFolder\myMatFile.mat';data = load(matfilePath);% to access the variabledata.(variableName); MATLAB: How to access data set from different folders finfo = dir('Instance*');finfo(~[finof.isfolder]) = [];foldernames = {finfo.name};ninst = length(foldernames);instance_data(ninst) = struct();for K = 1 : ninst thisfolder = foldernames{K}; instance_data(K).ProcMacMatrix = load(fullfile(thisfolder, 'ProcMacMatrix.dat')); % load the file %and similar for the other filesend Related QuestionHow to load variables in a .MAT file into the base workspace from a GUI in MATLAB 7.8 (R2009a)Does the first value in loop get overwrittenHow to load a .mat file from the parent directory
Best Answer