필터 지우기
필터 지우기

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 CenterFile Exchange에서 Live Scripts and Functions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by