フィルターのクリア

How to plot .mat file

16 ビュー (過去 30 日間)
Indrani
Indrani 2023 年 6 月 26 日
回答済み: Deepak 2023 年 6 月 26 日
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
Dyuman Joshi 2023 年 6 月 26 日
How exactly did you obtain this data, in this specific format?
Dyuman Joshi
Dyuman Joshi 2023 年 6 月 26 日
Unfortunately, you misunderstand.
What I meant was, the 730 files, how did you get them?

サインインしてコメントする。

回答 (1 件)

Deepak
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.

カテゴリ

Help Center および File ExchangeLive Scripts and Functions についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by