Quantcast
Viewing all articles
Browse latest Browse all 3

Answer by alrikai for How do I read several lines in Matlab with textscan?

For this case, you can do the following:

fid = fopen('indices.txt');num_ints = 7;num_rows = 4;format = [repmat('%d ', 1, num_ints), '%s'];weights = textscan(fid, format, num_rows);weights = [weights{1:num_ints}];fclose(fid);

The downside of course is that you have to know the number of rows that you're reading beforehand. You could try calling textscan in a loop, but that doesn't seem to be how it's meant to be used (and I would rather use fgetl instead if I'm trying to read the file line-by-line).


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>