This question is closed. Reopen it to edit or answer.

Load in multiple MATLAB files and extract 51st row

1 view (last 30 days)
Why does my code below not work? I want to read in all the files of a certain type which works. But I want to create a matrix of the 51st row of each file. Note that in the files, there is a single header row.
clear all
projectdirectory = 'C:/Path/';
dinfo = dir( fullfile(projectdirectory, 'msd.*.data') );
N = length(dinfo);
row51 = zeros(N, 2);
for K = 1 : N
filename = fullfile(projectdirectory, dinfo(K).name);
fid = fopen(filename, 'rt');
row51(K,:) = cell2mat( textscan(fid, '%f%f', 50, 'headerlines', 1, 'collectoutput', true) );
  1 Comment
Walter Roberson
Walter Roberson on 17 Aug 2018
Duplicate question answered at

Answers (0)


Community Treasure Hunt

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

Start Hunting!