📄 readdiffile.m
字号:
theta_all_save = theta_all;
elseif any(size(theta_all_save)~=size(theta_all)) || any( theta_all_save~=theta_all)
err = errordlg('Inconsistent wind direction list found in *DIF_EST_MIN_ALL section.', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
end
DIF_struct.X_min_est_all = X_min_est_all;
elseif strcmp( keyword, 'DIF_EST_MAX_BND' )
if index, continue, end;
if ~exist('n_m','var')
err = errordlg('The *MODEL_DIMENSIONS section must preceed the *DIF_EST_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_EST_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_EST_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_EST_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_est_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_EST_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_est_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_EST_MAX_BND section.', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
end
end
DIF_struct.X_max_est_bnd = X_max_est_bnd;
elseif strcmp( keyword, 'DIF_EST_MIN_BND' )
if index, continue, end;
if ~exist('n_m','var')
err = errordlg('The *MODEL_DIMENSIONS section must preceed the *DIF_EST_MIN_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_EST_MIN_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_EST_MIN_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_EST_MIN_BND section ' ...
' indicates that the number of wind directions per frame is inconsistent.'], err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
X_min_est_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_EST_MIN_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_min_est_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_EST_MIN_BND section.', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
end
end
DIF_struct.X_min_est_bnd = X_min_est_bnd;
% ================== L O A D D I S T R I B U T I O N S ==================
elseif strcmp( keyword, 'LOAD_DISTRIBUTION_MAX' )
if index, continue, end;
if ~exist('n_r','var')
err = errordlg('The *RESPONSE_NAMES section must preceed the *LOAD_DISTRIBUTION_MAX 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 *LOAD_DISTRIBUTION_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_r*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 *LOAD_DISTRIBUTION_MAX section ' ...
' indicates that the number of wind directions per frame is inconsistent.'], err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
% find number of attachment points from first row:
row_1 = strread(strtrim(dif_str_spc{1,:}));
n_a = length(row_1)-2; % number of attachment points
load_max = zeros(n_a,n_r,n_q,n_f);
for j = 1:n_f
for k = 1:n_r
for ii = 1:n_q
ind = n_q*n_r*(j-1)+n_q*(k-1)+ii; % number of the current row
row_ii = strread(strtrim(dif_str_spc{ind,:}));
if length(row_ii)~=n_a+2
err = errordlg(['The number of entries (' num2str(length(row_ii)) ') in row ' num2str(ind) ...
' of the *LOAD_DISTRIBUTION_MAX section (excluding header rows) does not match the number '...
' in the first row (' num2str(n_a+2) ').'], err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
theta(ii,1) = row_ii(1);
load_max(:,k,ii,j) = row_ii(3: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 *LOAD_DISTRIBUTION_MAX section.', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
end
end
DIF_struct.load_max = load_max;
elseif strcmp( keyword, 'LOAD_DISTRIBUTION_MIN' )
if index, continue, end;
if ~exist('n_r','var')
err = errordlg('The *RESPONSE_NAMES section must preceed the *LOAD_DISTRIBUTION_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 *LOAD_DISTRIBUTION_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_r*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 *LOAD_DISTRIBUTION_MIN section ' ...
' indicates that the number of wind directions per frame is inconsistent.'], err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
% find number of attachment points from first row:
row_1 = strread(strtrim(dif_str_spc{1,:}));
n_a = length(row_1)-2; % number of attachment points
load_min = zeros(n_a,n_r,n_q,n_f);
for j = 1:n_f
for k = 1:n_r
for ii = 1:n_q
ind = n_q*n_r*(j-1)+n_q*(k-1)+ii; % number of the current row
row_ii = strread(strtrim(dif_str_spc{ind,:}));
if length(row_ii)~=n_a+2
err = errordlg(['The number of entries (' num2str(length(row_ii)) ') in row ' num2str(ind) ...
' of the *LOAD_DISTRIBUTION_MIN section (excluding header rows) does not match the number '...
' in the first row (' num2str(n_a+2) ').'], err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
theta(ii,1) = row_ii(1);
load_min(:,k,ii,j) = row_ii(3: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 *LOAD_DISTRIBUTION_MIN section.', err_dlgname );
uiwait(err); DIF_struct.error = 1; return;
end
end
end
DIF_struct.load_min = load_min;
elseif strcmp( keyword, 'LOAD_DISTRIBUTION_MAX_ALL' )
if index, continue, end;
if ~exist('n_r','var')
err = errordlg('The *RESPONSE_NAMES section must preceed the *LOAD_DISTRIBUTION_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 *LOAD_DISTRIBUTION_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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -