fscanf
Read an array from a file according to a given size and format.
(data, count)=fscanf(fi, form, vsize)
Inputs
fi The reference to a file that has been opened for input.
form The format string.
vsize A two-element vector specifying the number of rows and columns to be read. See below for more details.
Outputs
data The array read from the file according to the specified format and size.


Description
If the number of rows specified in vsize (i.e. vsize[1] ) is inf, the elements are read till the end of file has been reached and they are stored in a vector. If the last input is of the form [m inf] the elements are read till the end of file has been reached and they are stored in a matrix of m rows and as many columns as are necessary to store all the input elements.
Example
>>a=rand(3,4)
>>a
    0.8937    0.0341    0.4218    0.9620
    0.7450    0.4891    0.7446    0.2077
    0.6824    0.6347    0.8586    0.8898
>>fi=fopen("fscanftest.d","w")
>> // Note that the array is output column by column.
>>fprintf(fi,"%12.4f %12.8f %20.16f \n",a)
>>fclose(fi)
>>showfile("fscanftest.d") 
      0.8937   0.74495452   0.6824312135948638
      0.0341   0.48906726   0.6347462685793776
      0.4218   0.74458489   0.8586068483123598
      0.9620   0.20765775   0.8897757460594888
>>fi=fopen("fscanftest.d","r")
>>b=fscanf(fi,"%f",[3, inf])
>>norm(a-b)
0