How to plot .mat file
16 ビュー (過去 30 日間)
古いコメントを表示
Hi!
I have loaded 730 files into matlab. The 730 files have been loaded as cells. Inside each cell is a structure which contains a .mat file. I need to plot the data of the .mat file.
How do I proceed? Is there an easier way to do it?
2 件のコメント
Dyuman Joshi
2023 年 6 月 26 日
Unfortunately, you misunderstand.
What I meant was, the 730 files, how did you get them?
回答 (1 件)
Deepak
2023 年 6 月 26 日
To plot the data from the .mat files loaded into MATLAB as cells, you can iterate over each cell, access the structure inside, and then load and plot the data from the .mat file. Here's an example of how you can proceed:
% Assuming your loaded files are stored in a cell array called 'loadedFiles'
numFiles = numel(loadedFiles);
% Preallocate a cell array to store the loaded data
data = cell(numFiles, 1);
% Iterate over each cell and load the .mat file data
for i = 1:numFiles
% Access the structure inside the cell
fileStruct = loadedFiles{i};
% Load the .mat file data
loadedData = load(fileStruct.matFileName); % Replace 'matFileName' with the actual field name
% Store the loaded data in the cell array
data{i} = loadedData;
% Plot the data
% Replace 'yourPlottingFunction' with the function you use to plot the frequency data
yourPlottingFunction(loadedData);
end
In this example, `loadedFiles` is assumed to be a cell array containing the loaded files. You can modify this code to match your specific variable names and structure field names.
The code iterates over each cell, accesses the structure inside using the appropriate field name, loads the .mat file data using the `load` function, stores the loaded data in the `data` cell array, and then plots the data using your chosen plotting function.
By using a loop, you can handle the 730 files efficiently. However, if you find this approach cumbersome, you can consider using the `cellfun` function to apply the loading and plotting operations to each cell in a more concise manner.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Workspace Variables and MAT-Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!