Loading Data from multiple .mat files in a folder and plotting
13 次查看(过去 30 天)
显示 更早的评论
![](/matlabcentral/answers/uploaded_files/1380869/received_2047988492062526.jpeg)
![](/matlabcentral/answers/uploaded_files/1380834/received_3403940723202308.jpeg)
![](/matlabcentral/answers/uploaded_files/1380844/20230511_154003.jpg)
I need to load data from these 10 .mat files and plot fx versus Uref. Can anyone please help me with a sample code. I have tried using the for loop but it's not loading all the files.
回答(1 个)
Swaraj
2023-5-31
Hi Imtiaz,
I understand that you want to load multiple .mat file from a folder and plot the data from it and you are facing problem in loading the .mat files.
To check your issue, I created a folder with following files.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1399004/image.png)
I wrote the following sample code, and I was able to load the specified three .mat file and ignoring the excel file.
currentDir = pwd;
fileList = dir(currentDir);
fileList = {fileList.name};
filteredFileList = fileList(cellfun(@(x) contains(x, 'OCTAGON') && contains(x,'.mat'), fileList));
for i=1:length(filteredFileList)
file = load(filteredFileList{i});
%Do your task with the file here
end
This is just the sample code. You can rewrite it as per your requirements.
Hope it helps!!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!