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

📄 readbldgfile.m

📁 低矮房屋风压系数、风荷载计算分析matlab程序
💻 M
📖 第 1 页 / 共 2 页
字号:
        bldg_struct.z0 = z0;

    elseif strcmp( keyword, 'RESPONSE_NAMES' )
        % At least one line expected with two entries per line (response #, name):
        if i == length(key_ind)
            resp_names_str = file_contents(key_ind(i)+2:file_lines);
        else
            resp_names_str = file_contents(key_ind(i)+2:key_ind(i+1)-1);
        end
        n_r1 = size(resp_names_str,1);
        for j = 1:n_r1
            % trim trailing spaces, read numerical values, and place in matrix:
            row_j = resp_names_str{j};
            [num_str, rem] = strtok( row_j, ',');
            [resp_str, rem] = strtok( rem, ',');
            [runit_str, rem] = strtok( rem, ',' );
            if isempty(num_str) || str2num(num_str)~=j
                err = errordlg(['The response number (' num_str ') in row '  num2str(j) ' of the *RESPONSE_NAMES section ' ...
                    ' is not allowed. Response numbers must start at 1 and increment by 1.'], err_dlgname );
                uiwait(err); bldg_struct.error = 1; return;
            elseif isempty(resp_str) | isempty(runit_str)
                err = errordlg({['Row ' num2str(row_j(1)) ' of the *RESPONSE_NAMES section contains fewer than the expected ' ...
                    'number of entries (3). Quoting from input file:'],['     ' row_j ]}, err_dlgname );
                uiwait(err); bldg_struct.error = 1; return;
            elseif ~isempty(setdiff(rem,', '))
                err = errordlg({['Row ' num2str(row_j(1)) ' of the *RESPONSE_NAMES section contains more than the expected ' ...
                    'number of entries (3). Quoting from input file:'],['     ' row_j ]}, err_dlgname );
                uiwait(err); bldg_struct.error = 1; return;
            else
                resp_names{j} = resp_str;
                resp_units{j} = runit_str;
            end
        end
        bldg_struct.resp_names = resp_names;
        bldg_struct.resp_units = resp_units;
        
    elseif strcmp( keyword, 'ATTACHMENT_LOCATIONS' )
        % At least four rows expected, with three entries per row: (index, face #, s-coordinate)
        if i == length(key_ind)
            attach_str = file_contents(key_ind(i)+2:file_lines);
        else
            attach_str = file_contents(key_ind(i)+2:key_ind(i+1)-1);
        end
        attach_str_spc = strrep( attach_str, ',', ' ' ); % replace commas with spaces
        n_a1 = size(attach_str_spc,1); % number of attachment points
        % check number of entries in first row:
        for j = 1:n_a1
            row_j = strread(strtrim(attach_str_spc{j,:}));
            if row_j(1)~=j
                err = errordlg(['The index number (' num2str(row_j(1)) ') in row '  num2str(j) ' of the *ATTACHMENT_LOCATIONS section ' ...
                    'is not allowed. Index numbers must start at 1 and increment by 1.'], err_dlgname );
                uiwait(err); bldg_struct.error = 1; return;
            elseif length(row_j)~=3
                err = errordlg({['Row ' num2str(j) ' of the *ATTACHMENT_LOCATIONS section does not contain '...
                    'the expected number of entries (3). Quoting from input file:'],...
                    ['     >> '  inf_coeff_str{j} ' <<' ]}, err_dlgname );
                uiwait(err); bldg_struct.error = 1; return;
            end
            attach_pts(j,:) = row_j(2:3);
        end
        for j = 1:4
            if any(attach_pts(find(attach_pts(:,1)==j),2)~=sort(attach_pts(find(attach_pts(:,1)==j),2)))
                err = errordlg(['The s-coordinates for face ' num2str(j) ' in the *ATTACHMENT_LOCATIONS section are not ' ...
                    'sorted in ascending order, as is required.'], err_dlgname );
                uiwait(err); bldg_struct.error = 1; return;
            end
        end
        bldg_struct.attach_pts = attach_pts;
        
    elseif strcmp( keyword, 'INFLUENCE_COEFFICIENTS' )
        % At least four rows expected, with at least two entries per row:
        if i == length(key_ind)
            inf_coeff_str = file_contents(key_ind(i)+2:file_lines);
        else
            inf_coeff_str = file_contents(key_ind(i)+2:key_ind(i+1)-1);
        end
        inf_coeff_str_spc = strrep( inf_coeff_str, ',', ' ' ); % replace commas with spaces
        n_a2 = length(inf_coeff_str_spc); % number of attachment points
        % check number of entries in first row:
        n_cols = length(strread(strtrim( inf_coeff_str_spc{1,:} ))); % total number of columns
        n_r2 = n_cols-1; % number of influence coefficient vectors defined (first columns is index number)
        inf_coeff = zeros(size(inf_coeff_str_spc,1),n_r2); % initialize matrix for storing numerical values
        for j = 1:size(inf_coeff,1)
            % trim trailing spaces, read numerical values, and place in matrix:
            row_j = strread(strtrim(inf_coeff_str_spc{j,:}));
            if row_j(1)~=j
                err = errordlg(['The index number (' num2str(row_j(1)) ') in row '  num2str(j) ' of the *INFLUENCE_COEFFICIENTS section ' ...
                    'is not allowed. Index numbers must start at 1 and increment by 1.'], err_dlgname );
                uiwait(err); bldg_struct.error = 1; return;
            elseif length(row_j)~=n_cols
                err = errordlg({['Row ' num2str(j) ' of the *INFLUENCE_COEFFICIENTS section contains a different number of entries than row 1. ' ...
                    'Quoting from input file:'],['   Line 1:  >> '  inf_coeff_str{1} ' <<'], ...
                    ['   Line ' num2str(j) ':  >> '  inf_coeff_str{j} ' <<' ]}, err_dlgname );
                uiwait(err); bldg_struct.error = 1; return;
            end
            inf_coeff(j,:) = row_j(2:end);
        end
        bldg_struct.inf_coeff = inf_coeff;
    
    
    else
        err = errordlg(['The keyword ' keyword ' is unrecognized.'], err_dlgname);
        uiwait(err); bldg_struct.error = 1; return;
    end
    
end


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

% 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); bldg_struct.error = 1; return;
end

if n_a1~=n_a2
    errordlg(['The number of columns in the *ATTACHMENT_LOCATIONS section (' num2str(n_a1) ') ' ...
        'does not match the number of columns in the *INFLUENCE_COEFFICIENTS section (' num2str(n_a2) ').'], err_dlgname );
    bldg_struct.error = 1; return;
elseif n_r1~=n_r2
    errordlg(['The number of responses defined in the *RESPONSE_NAMES section (' num2str(n_r1) ') ' ...
        'does not match the number of responses in the *INFLUENCE_COEFFICIENTS section (' num2str(n_r2) ').'], err_dlgname );
    bldg_struct.error = 1; return;
end
n_a = n_a1;
n_r = n_r1;
    
if frame_coords(1,1)==frame_coords(1,2) & frame_coords(1,1)>(frame_coords(1,3)-frame_coords(1,2))/5
    button = questdlg(['The frame at y = ' num2str(frame_coords(1,2)) ' has been selected for analysis, but no previous frame has been specified. ' ...
        'Therefore, pressures acting on the building surface for y < '  num2str(frame_coords(1,2)) ' will be neglected in computing the ' ...
        'response of this frame. Press "Continue" to neglect these pressures. To define a previous frame, press "Cancel" to abort the ' ...
        'analysis; then modify the building input file and restart the analysis.'],...
        'Warning: Questionable frame definition', 'Continue', 'Cancel', 'Cancel');
    uiwait(button);
    if strcmp(button,'Cancel')
        bldg_struct.error = 1; return;
    end
end
if frame_coords(end,2)==frame_coords(end,3) & L-frame_coords(end,3)>(frame_coords(end,2)-frame_coords(end,1))/5
    button = questdlg(['The frame at y = ' num2str(frame_coords(end,2)) ' has been selected for analysis, but no subsequent frame has been specified. ' ...
        'Therefore, pressures acting on the building surface for y > '  num2str(frame_coords(end,2)) ' will be neglected in computing the ' ...
        'response of this frame. Press "Continue" to neglect these pressures. To define a subsequent frame, press "Cancel" to abort the ' ...
        'analysis; then modify the building input file and restart the analysis.'],...
        'Warning: Questionable frame definition', 'Continue', 'Cancel', 'Cancel');
    uiwait(button);
    if strcmp(button,'Cancel')
        bldg_struct.error = 1; return;
    end
end

⌨️ 快捷键说明

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