⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readdiffile.m

📁 低矮房屋风压系数、风荷载计算分析matlab程序
💻 M
📖 第 1 页 / 共 5 页
字号:
        % 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_r*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 *LOAD_DISTRIBUTION_MAX_ALL 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_all = zeros(n_a,n_r,n_qa,n_f);
        for j = 1:n_f
            for k = 1:n_r
                for ii = 1:n_qa
                    ind = n_qa*n_r*(j-1)+n_qa*(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_ALL 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_all(ii,1) = row_ii(1);
                    load_max_all(:,k,ii,j) = row_ii(3:end);
                end
                if ~exist('theta_all_save','var')
                    DIF_struct.theta_all= theta_all;
                    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 *LOAD_DISTRIBUTION_MAX_ALL section.', err_dlgname );
                    uiwait(err); DIF_struct.error = 1; return;
                end
            end
        end
        DIF_struct.load_max_all = load_max_all;
        
    elseif strcmp( keyword, 'LOAD_DISTRIBUTION_MIN_ALL' )
        if index, continue, end;

        if ~exist('n_r','var')
            err = errordlg('The *RESPONSE_NAMES section must preceed the *LOAD_DISTRIBUTION_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 *LOAD_DISTRIBUTION_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_r*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 *LOAD_DISTRIBUTION_MIN_ALL section ' ...
                ' indicates that the number of wind directions per response quantity 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_all = zeros(n_a,n_r,n_qa,n_f);
        for j = 1:n_f
            for k = 1:n_r
                for ii = 1:n_qa
                    ind = n_qa*n_r*(j-1)+n_qa*(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_ALL 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_all(ii,1) = row_ii(1);
                    load_min_all(:,k,ii,j) = row_ii(3:end);
                end
                if ~exist('theta_all_save','var')
                    DIF_struct.theta_all= theta_all;
                    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 *LOAD_DISTRIBUTION_MIN_ALL section.', err_dlgname );
                    uiwait(err); DIF_struct.error = 1; return;
                end
            end
        end
        DIF_struct.load_min_all = load_min_all;

    elseif strcmp( keyword, 'LOAD_DISTRIBUTION_MAX_BND' )
        if index, continue, end;

        if ~exist('n_m','var')
            err = errordlg('The *MODEL_DIMENSIONS section must preceed the *LOAD_DISTRIBUTION_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 *LOAD_DISTRIBUTION_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 *LOAD_DISTRIBUTION_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_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_BND 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_bnd = zeros(n_a,n_r,n_m*n_q,n_f);
        for j = 1:n_f
            for k = 1:n_r
                for ii = 1:n_m
                    for jj = 1:n_q
                        ind = n_q*n_m*n_r*(j-1)+n_q*n_m*(k-1)+n_q*(ii-1)+jj; % number of the current row
                        row_jj = strread(strtrim(dif_str_spc{ind,:}));
                        if length(row_jj)~=n_a+2
                            err = errordlg(['The number of entries (' num2str(length(row_jj)) ') in row ' num2str(ind) ...
                                ' of the *LOAD_DISTRIBUTION_MAX_BND 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(jj,1) = row_jj(1);
                        load_max_bnd(:,k,n_q*(ii-1)+jj,j) = row_jj(3: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_BND section.', err_dlgname );
                            uiwait(err); DIF_struct.error = 1; return;
                        end
                    end
                end
            end
        end
        DIF_struct.load_max_bnd = load_max_bnd;

    elseif strcmp( keyword, 'LOAD_DISTRIBUTION_MIN_BND' )
        if index, continue, end;

        if ~exist('n_m','var')
            err = errordlg('The *MODEL_DIMENSIONS section must preceed the *LOAD_DISTRIBUTION_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 *LOAD_DISTRIBUTION_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 *LOAD_DISTRIBUTION_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_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_BND 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_bnd = zeros(n_a,n_r,n_m*n_q,n_f);
        for j = 1:n_f
            for k = 1:n_r
                for ii = 1:n_m
                    for jj = 1:n_q
                        ind = n_q*n_m*n_r*(j-1)+n_q*n_m*(k-1)+n_q*(ii-1)+jj; % number of the current row
                        row_jj = strread(strtrim(dif_str_spc{ind,:}));
                        if length(row_jj)~=n_a+2
                            err = errordlg(['The number of entries (' num2str(length(row_jj)) ') in row ' num2str(ind) ...
                                ' of the *LOAD_DISTRIBUTION_MIN_BND 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(jj,1) = row_jj(1);
                        load_min_bnd(:,k,n_q*(ii-1)+jj,j) = row_jj(3: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_BND section.', err_dlgname );
                            uiwait(err); DIF_struct.error = 1; return;
                        end
                    end
                end
            end
        end
        DIF_struct.load_min_bnd = load_min_bnd;
        
    else
        err = errordlg(['The keyword ' keyword ' is unrecognized.'], err_dlgname);
        uiwait(err); DIF_struct.error = 1; return;
    end
    
end

% required keyword entries:
required_keywords = {'UNITS','MODEL_TERRAIN','FRAME_LOCATIONS','RESPONSE_NAMES','ATTACHMENT_LOCATIONS','BUILDING_DIMENSIONS','MODEL_DIMENSIONS'};

% check that all required keywords are included:
missing_keywords = setdiff( required_keywords, keyword_list );
missing_key_char = [];
if ~isempty(missing_keywords)
    for i = 1:length(missing_keywords)
        missing_key_char = [missing_key_char missing_keywords{i}];
        if i ~= length(missing_keywords)
            missing_key_char = [missing_key_char ', '];
        end
    end
    err = errordlg({'The following required keywords are missing from the input file:',['     ' missing_key_char ]}, err_dlgname);
    uiwait(err); DIF_struct.error = 1; return;
end

status = fclose(fid);
if status==-1
    err = errordlg(['Unable to close file: '  DIF_full_filename ], err_dlgname );
    uiwait(err); DIF_struct.error = 1; return;
end 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -