only reading and plotting data for one file while I want it to read and plot data for 12 files

1 view (last 30 days)
I am trying to read column 4 and 10 from 12 excel files and plot 12 graphs from it but I am only getting plot 1. Below is the code can you guide me how to do it properly.
close all; clear all; clc;
% To access the folder
folder = fullfile('C:','Users','muhammad','Documents','PhD_3rdYr','Experiments_2021','performance_110');
files = dir( fullfile(folder, '*.ods') );
% Reading and extracting data from 12 excel files hence plotting
for ii = 1:length(12)
data = readmatrix(fullfile(files(ii).folder,files(ii).name), 'NumHeaderLines', 1)
x= data(:,10)
% Plotting data
hold on
%Spacing and griding
xlim([0 6])
ylim([0 0.8])
hold on
grid on
% Outlet starting
y = 0.237;
line ([0,5],[y,y],'color','r');
txt = {'Outlet,Invert Level = 237 mm'};
% Design Head
y = 0.737; %17 mm
line ([0,5],[y,y],'color','r');
txt = {'Design Head = 737 mm'};
% Design Limit Box
x =5;
line ([x,x],[0,0.737],'color','r')
hold on
%Chart Representation
title('Outlet-110 mm');
xlabel('flowrate (l/s)');
ylabel('Head (m))');
% legend('VFC');

Accepted Answer

Mathieu NOE
Mathieu NOE on 21 Apr 2021
all plots are updated at each loop iteration on the same figure(1)
so at the end you have only one figure showing the last iteration
change in your code : figure(1) into figure(ii)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by