📄 readdiffile.m
字号:
uiwait(err); DIF_struct.error = 1; return;
end
if ~exist('n_f','var')
err = errordlg('The *FRAME_LOCATIONS section must preceed the *DIF_OBS_MAX section', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
if i == length(key_ind)
dif_str = file_contents(key_ind(i)+1:file_lines);
else
dif_str = file_contents(key_ind(i)+1:key_ind(i+1)-1);
end
% Eliminate header rows:
num_ind = intersect(find(~strncmp('Frame',dif_str,5)),find(~strncmp('Wind',dif_str,4)));
dif_str = dif_str(num_ind);
dif_str_spc = strrep( dif_str, ',', ' ' ); % replace commas with spaces
n_q = size(dif_str,1)/n_f;
if round(n_q)~=n_q
err = errordlg(['The number of rows (' num2str(size(dif_str,1)) ') in the *DIF_OBS_MAX section ' ...
' indicates that the number of wind directions per frame is inconsistent.'], err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
X_max_obs = zeros(n_r,n_q,n_f);
for j = 1:n_f
for k = 1:n_q
ind = n_q*(j-1)+k; % number of the current row (skip two headers for each frame)
row_k = strread(strtrim(dif_str_spc{ind,:}));
if length(row_k)~=n_r+1
err = errordlg(['Row ' num2str(ind) ' of the *DIF_OBS_MAX section (excluding headers) contains ' ...
num2str(length(row_k)) ' entries (' num2str(n_r+1) ' expected).'], err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
theta(k,1) = row_k(1);
X_max_obs(:,k,j) = row_k(2:end);
end
if ~exist('theta_save','var')
DIF_struct.theta = theta;
theta_save = theta;
else
if any(size(theta_save)~=size(theta)) || any( theta_save~=theta)
err = errordlg('Inconsistent wind direction list found in *DIF_OBS_MAX section.', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
end
end
DIF_struct.X_max_obs = X_max_obs;
elseif strcmp( keyword, 'DIF_OBS_MIN' )
if index, continue, end;
if ~exist('n_r','var')
err = errordlg('The *RESPONSE_NAMES section must preceed the *DIF_OBS_MIN section', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
if ~exist('n_f','var')
err = errordlg('The *FRAME_LOCATIONS section must preceed the *DIF_OBS_MIN section', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
if i == length(key_ind)
dif_str = file_contents(key_ind(i)+1:file_lines);
else
dif_str = file_contents(key_ind(i)+1:key_ind(i+1)-1);
end
% Eliminate header rows:
num_ind = intersect(find(~strncmp('Frame',dif_str,5)),find(~strncmp('Wind',dif_str,4)));
dif_str = dif_str(num_ind);
dif_str_spc = strrep( dif_str, ',', ' ' ); % replace commas with spaces
n_q = size(dif_str,1)/n_f;
if round(n_q)~=n_q
err = errordlg(['The number of rows (' num2str(size(dif_str,1)) ') in the *DIF_OBS_MIN section ' ...
' indicates that the number of wind directions per frame is inconsistent.'], err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
X_min_obs = zeros(n_r,n_q,n_f);
for j = 1:n_f
for k = 1:n_q
ind = n_q*(j-1)+k; % number of the current row (skip two headers for each frame)
row_k = strread(strtrim(dif_str_spc{ind,:}));
if length(row_k)~=n_r+1
err = errordlg(['Row ' num2str(ind) ' of the *DIF_OBS_MIN section (excluding header rows) contains ' ...
num2str(length(row_k)) ' entries (' num2str(n_r+1) ' expected).'], err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
theta(k,1) = row_k(1);
X_min_obs(:,k,j) = row_k(2:end);
end
if ~exist('theta_save','var')
DIF_struct.theta = theta(:);
theta_save = theta;
else
if any(size(theta_save)~=size(theta)) || any( theta_save~=theta)
err = errordlg('Inconsistent wind direction lists found in *DIF_OBS_MIN section.', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
end
end
DIF_struct.X_min_obs = X_min_obs;
elseif strcmp( keyword, 'DIF_OBS_MAX_ALL' )
if index, continue, end;
if ~exist('n_r','var')
err = errordlg('The *RESPONSE_NAMES section must preceed the *DIF_OBS_MAX_ALL section', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
if ~exist('n_f','var')
err = errordlg('The *FRAME_LOCATIONS section must preceed the *DIF_OBS_MAX_ALL section', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
if i == length(key_ind)
dif_str = file_contents(key_ind(i)+1:file_lines);
else
dif_str = file_contents(key_ind(i)+1:key_ind(i+1)-1);
end
% Eliminate header rows:
num_ind = intersect(find(~strncmp('Frame',dif_str,5)),find(~strncmp('Wind',dif_str,4)));
dif_str = dif_str(num_ind);
dif_str_spc = strrep( dif_str, ',', ' ' ); % replace commas with spaces
n_qa = size(dif_str,1)/n_f; % total number of wind directions
if round(n_qa)~=n_qa
err = errordlg(['The number of rows (' num2str(size(dif_str,1)) ') in the *DIF_OBS_MAX_ALL section ' ...
' indicates that the number of wind directions per frame is inconsistent.'], err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
X_max_obs_all = zeros(n_r,n_qa,n_f);
for j = 1:n_f
for k = 1:n_qa
ind = n_qa*(j-1)+k; % number of the current row
row_k = strread(strtrim(dif_str_spc{ind,:}));
if length(row_k)~=n_r+1
err = errordlg(['Row ' num2str(ind) ' of the *DIF_OBS_MAX_ALL section (excluding header rows) contains '...
num2str(length(row_k)) ' entries (' num2str(n_r+1) ' expected).'], err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
theta_all(k,1) = row_k(1);
X_max_obs_all(:,k,j) = row_k(2:end);
end
if ~exist('theta_all_save','var')
DIF_struct.theta_all= theta_all;
theta_all_save = theta_all;
else
if any(size(theta_all_save)~=size(theta_all)) || any( theta_all_save~=theta_all)
err = errordlg('Inconsistent wind direction list found in *DIF_OBS_MAX_ALL section.', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
end
end
DIF_struct.X_max_obs_all = X_max_obs_all;
elseif strcmp( keyword, 'DIF_OBS_MIN_ALL' )
if index, continue, end;
if ~exist('n_r','var')
err = errordlg('The *RESPONSE_NAMES section must preceed the *DIF_OBS_MIN_ALL section', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
if ~exist('n_f','var')
err = errordlg('The *FRAME_LOCATIONS section must preceed the *DIF_OBS_MIN_ALL section', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
if i == length(key_ind)
dif_str = file_contents(key_ind(i)+1:file_lines);
else
dif_str = file_contents(key_ind(i)+1:key_ind(i+1)-1);
end
% Eliminate header rows:
num_ind = intersect(find(~strncmp('Frame',dif_str,5)),find(~strncmp('Wind',dif_str,4)));
dif_str = dif_str(num_ind);
dif_str_spc = strrep( dif_str, ',', ' ' ); % replace commas with spaces
n_qa = size(dif_str,1)/n_f; % total number of wind directions
if round(n_qa)~=n_qa
err = errordlg(['The number of rows (' num2str(size(dif_str,1)) ') in the *DIF_OBS_MIN_ALL section ' ...
' indicates that the number of wind directions per frame is inconsistent.'], err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
X_min_obs_all = zeros(n_r,n_qa,n_f);
for j = 1:n_f
for k = 1:n_qa
ind = n_qa*(j-1)+k; % number of the current row
row_k = strread(strtrim(dif_str_spc{ind,:}));
if length(row_k)~=n_r+1
err = errordlg(['Row ' num2str(ind) ' of the *DIF_OBS_MIN_ALL section (excluding header rows) contains ' ...
num2str(length(row_k)) ' entries (' num2str(n_r+1) ' expected).'], err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
theta_all(k,1) = row_k(1);
X_min_obs_all(:,k,j) = row_k(2:end);
end
if ~exist('theta_all_save','var')
DIF_struct.theta_all= theta_all;
theta_all_save = theta_all;
else
if any(size(theta_all_save)~=size(theta_all)) || any( theta_all_save~=theta_all)
err = errordlg('Inconsistent wind direction list found in *DIF_OBS_MIN_ALL section.', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
end
end
DIF_struct.X_min_obs_all = X_min_obs_all;
elseif strcmp( keyword, 'DIF_OBS_MAX_BND' )
if index, continue, end;
if ~exist('n_m','var')
err = errordlg('The *MODEL_DIMENSIONS section must preceed the *DIF_OBS_MAX_BND section', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
if ~exist('n_r','var')
err = errordlg('The *RESPONSE_NAMES section must preceed the *DIF_OBS_MAX_BND section', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
if ~exist('n_f','var')
err = errordlg('The *FRAME_LOCATIONS section must preceed the *DIF_OBS_MAX_BND section', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
if i == length(key_ind)
dif_str = file_contents(key_ind(i)+1:file_lines);
else
dif_str = file_contents(key_ind(i)+1:key_ind(i+1)-1);
end
% Eliminate header rows:
num_ind = intersect(find(~strncmp('Frame',dif_str,5)),intersect(find(~strncmp('Model',dif_str,5)),find(~strncmp('Wind',dif_str,4))));
dif_str = dif_str(num_ind);
dif_str_spc = strrep( dif_str, ',', ' ' ); % replace commas with spaces
n_q = size(dif_str,1)/(n_m*n_f); % total number of wind directions
if round(n_q)~=n_q
err = errordlg(['The number of rows (' num2str(size(dif_str,1)) ') in the *DIF_OBS_MAX_BND section ' ...
' indicates that the number of wind directions per frame is inconsistent.'], err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
X_max_obs_bnd = zeros(n_r,n_q*n_m,n_f);
for j = 1:n_f
for k = 1:n_m
for ii = 1:n_q
ind = n_q*n_m*(j-1)+n_q*(k-1)+ii; % number of the current row
row_ii = strread(strtrim(dif_str_spc{ind,:}));
if length(row_k)~=n_r+1
err = errordlg(['Row ' num2str(ind) ' of the *DIF_OBS_MAX_BND section (excluding header rows) contains '...
num2str(length(row_k)) ' entries (' num2str(n_r+1) ' expected).'], err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
theta(ii,1) = row_ii(1);
X_max_obs_bnd(:,n_q*(k-1)+ii,j) = row_ii(2:end);
end
if ~exist('theta_save','var')
DIF_struct.theta = theta;
theta_save = theta;
elseif any(size(theta_save)~=size(theta)) || any( theta_save~=theta)
err = errordlg('Inconsistent wind direction list found in *DIF_OBS_MAX_BND section.', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -