only reading and plotting data for one file while I want it to read and plot data for 12 files
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
muhammad choudhry
le 19 Avr 2021
Réponse apportée : Mathieu NOE
le 21 Avr 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 commentaires
Réponse acceptée
Mathieu NOE
le 21 Avr 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!