필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
Hi,
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.
Code:
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)
y=data(:,4)
figure(1)
% Plotting data
plot(x,y,'x','LineWidth',0.5);
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'};
text(1,0.25,txt)
% Design Head
y = 0.737; %17 mm
line ([0,5],[y,y],'color','r');
txt = {'Design Head = 737 mm'};
text(1,0.76,txt)
% 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');
end

채택된 답변

Mathieu NOE
Mathieu NOE 2021년 4월 21일
hello
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)

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by