only reading and plotting data for one file while I want it to read and plot data for 12 files
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
muhammad choudhry
am 19 Apr. 2021
Beantwortet: Mathieu NOE
am 21 Apr. 2021
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
0 Kommentare
Akzeptierte Antwort
Mathieu NOE
am 21 Apr. 2021
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!