So i have some data with unknown number of lines. They contain the numbers 1 or -1, text or empty lines. How do i fgetl to obtain only the numbers(no empty lines and text lines) to store into a matrix? say for example my data is
1 1 -1 1 1 -11 -1 1 1 -1 1sdasr-1 1 1 1 -1 -1
where — is an empty line, what should my loop look like using a while loop to extract just the 1s and -1s into the matrix in the correct row and column they come in? I am thinking about using a while loop to fgetl all the lines but don't know what condition to use. Thanks
NB: Edited using {}Code to reflect actual file format — dpb
Best Answer