Creating folder and saving file using imwrite

조회 수: 3 (최근 30일)
Indrani
Indrani 2023년 6월 16일
답변: Ronit 2023년 6월 16일
I have a parent (year) folder. Inside the parent folder are subfolders (months) with the number of .csv files equal to the days of the month. I have imported the data to matlab as a table. The table has freuency values for each minute of the day for the entire 24 hours. I have plotted the data for each hour. I now want to make a folder for each month to save the graphs using imwrite.
How do I proceed?

답변 (1개)

Ronit
Ronit 2023년 6월 16일
To proceed, you can use Matlab's built-in mkdir function to create a new folder for each month. You can then loop through each month folder and save the plots using the imwrite function.
Follow the steps:-
  1. Get the list of month subfolders.
  2. Loop through month subfolders.
  3. Create new folder for current month in loop to save plots.
  4. Load data for current month, then current day and then loop for every hour and plot the data.
  5. Save the plot as PNG file with the particular hour name using imwrite.
The directory structure should look like this:-
ParentFolder/
|____Month1/
| |____01/
| | |____data.csv
| |____ ...
| |____31/
| | |____data.csv
| |____Plots/ <-- New subfolder to save plots
|____ ...
|____MonthN/
|____ ...

카테고리

Help CenterFile Exchange에서 Bar Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by