clear all
close all
clc
%%
% This script can be used to load a single void (.v) file into MatLab's
% workspace (created 01/2021, A. Döß, HZDR)
% 1. Add the directory containing .v Files to the Matlab Workspace
 
%% Choose file to open
filename = 'M11_1_G10_10D_X_Sensor_1.v'; %example
FID=fopen(fullfile(filename),'rb');

%% Wire-mesh sensor properties
% mode = '50'; % use this for DN 50 data
mode = '200'; % use this for DN 200 data

switch mode
    case '50'
        dimX = 16; dimY = 16; %wire grid
        freq = 1e4;  % measurement frequency
        r_time = 60; % recording time in s
        frames_total = freq*r_time;
        startframe   =1;
        endframe     =frames_total; 
        
    case '200'
        dimX = 64; dimY = 64; %wire grid
        freq = 2.5e3;  % measurement frequency
        r_time = 20; % recording time in s
        frames_total = freq*r_time;
        startframe   =1;
        endframe     =frames_total; 
end

%% open data
framerange= endframe-startframe; 
fseek(FID,dimX * dimY * startframe,'bof');
vdata = fread(FID,dimX * dimY * framerange,'uint8');
fclose(FID);
%% reshape into an array [dimX, dimy, frames]
DATA =reshape(vdata, [dimX dimY framerange]);
clear vdata FID
