how to read 4th and 10th column of 12 excel files from folder and then plot 4th and 10th column of each excel file

1 view (last 30 days)
Hi,
How can I read the specific columns and from the bunch of excel files and then use the column data to plot the sub-plot of graphs?
Sofar,
close all; clear all; clc;
folder = fullfile('C:','Users','muhammad','Documents','PhD_3rdYr','Experiments_2021','performance_110');
files = dir( fullfile(folder, '*.ods') );

Accepted Answer

Shivang Srivastava
Shivang Srivastava on 23 Apr 2021
As per my understanding you want to read all files in a directory and read the excel files and plot the values in particular columns.
currentpath = pwd;
dataPath = string(currentpath)+ '\data';
allFiles = dir(dataPath);
sz = size(allFiles,1);
figure
for i = [3:sz]
% The index start from 3 because for i = 1 & 2,
% allFiles.names is '.' & '..' respectively.
path = dataPath + '\' + allFiles(i).name;
data = readtable(path);
hold on
plot(data.Var4)
hold on
plot(data.Var10)
end
Here, Var4 and Var10 are used for column 4 & 10. You can use Var<n> where n is the column number.

More Answers (0)

Categories

Find more on Data Import from MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!