Divide a column of a datafile through a constant value
Show older comments
I have a large number of datafiles (.txt file) and I need to divide one of the columns to a constant number. What is the short way to do it.
3 Comments
Dyuman Joshi
on 23 May 2022
Import your data (preferably in a table/double matrix) and then perform the operation.
How large is your data exactly?
Shivu
on 23 May 2022
Shivu
on 23 May 2022
Answers (1)
KSSV
on 23 May 2022
txtFiles = dir('*.txt') ; % you are in the folder of text files
N = length(txtFiles) ; % total files
% loop for each file
for i = 1:N
txtFile = txtFiles(i).name ;
T = readtable(txtFile) ; % also have a look on load, importdata
T.(1) = T.(1)/100 ; % divide first column by 100
end
Categories
Find more on Large Files and Big Data 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!