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

📄 plotbldg.m

📁 低矮房屋风压系数、风荷载计算分析matlab程序
💻 M
字号:
function plotBLDG( bldg_struct )

% Create labels for frames to be used in popup menus:
length_units = bldg_struct.length_units;
frame_loc = bldg_struct.frame_coords(:,2);
n_f = length(frame_loc);
for i = 1:n_f
    frame_label{i} = ['Frame ' num2str(i) ': y = ' num2str(frame_loc(i)) ' ' length_units];
end

% Create labels for responses to be used in popup menus:
resp_names = bldg_struct.resp_names;
resp_units = bldg_struct.resp_units;
n_r = length(resp_names);
for i = 1:n_r
    resp_label{i} = ['Response ' num2str(i) ': ' resp_names{i} ' (' resp_units{i} ')'];
end

f = 1;
r = 1;

scrsz = get(0,'ScreenSize');
oX = scrsz(3)*.05;
oY = scrsz(4)*.1;
dX = scrsz(3)*.9;
dY = scrsz(4)*.8;
clr = get(0,'DefaultUicontrolBackgroundColor');

top_h = 5; % height of frame/response selection panel at top
btm_h = 5; % height of menu panel at bottom

% ************************* Create figure for plotting frame locations:

frame_fig = figure('Color',clr,'Position',[oX oY dX dY],'Name','Building Input File Plotting','NumberTitle','off'); 
set( frame_fig, 'Units', 'character');
Size = get( frame_fig, 'Position');
X0 = Size(3);
Y0 = Size(4);
plot_h = Y0 - top_h - btm_h;
toggle_w = X0/3-2; % width of toggle buttons on menu panel at bottom
toggle_h = btm_h-1; % height of toggle buttons on menu panel at bottom


% create panel for selecting frame to plot:
frame_select_panel = uipanel('Parent',frame_fig,'BackgroundColor',clr,'Units','character','Position',[0 Y0-top_h X0 top_h],...
    'FontSize',12,'FontWeight','bold','TitlePosition','lefttop','Title','Select frame to plot:');
frame_popup = uicontrol(frame_select_panel, 'Style', 'popupmenu', 'String',frame_label,'Value',f,...
    'Units','characters','Position',[2 1 70 1.5],'BackgroundColor','w',...
    'Callback',@FrameSelectCallback);

frame_plot_panel = uipanel('Parent',frame_fig,'BackgroundColor',clr,'Units','character','Position',[0 btm_h X0 plot_h],...
    'FontSize',12,'FontWeight','bold','TitlePosition','lefttop',...
    'Title','Plot of frame locations (selected frame shown in red; neighboring frames in blue and green):');
frame_plot_axes = axes('Parent',frame_plot_panel);

frame_menu_panel = uipanel('Parent',frame_fig,'BackgroundColor',clr,'Units','character','Position',[0 0 X0 btm_h]);

frame_frame_toggle = uicontrol(frame_menu_panel, 'Style','togglebutton','String','Frame Locations','Value',1,'Enable','inactive',...
    'BackgroundColor',.87*[1 1 1],'Units','characters','Position',[X0/6-toggle_w/2 0.5 toggle_w toggle_h]);
frame_IC_toggle = uicontrol(frame_menu_panel, 'Style','togglebutton','String','Influence Coefficients','Value',0,...
    'Units','characters','Position',[X0/2-toggle_w/2 0.5 toggle_w toggle_h],...
    'Callback',@ICToggleCallback);
frame_exit_button = uicontrol(frame_menu_panel, 'Style','pushbutton','String','Close',...
    'Units','characters','Position',[X0*5/6-toggle_w/2 0.5 toggle_w toggle_h],...
    'Callback',@ExitCallback);

% Create figure for plotting influence coefficients:

IC_fig = figure('Color',clr,'Position',[oX oY dX dY],'Name','Building Input File Plotting','NumberTitle','off'); 
set( IC_fig, 'Units', 'character');
Size = get( IC_fig, 'Position');
X0 = Size(3);
Y0 = Size(4);
plot_h = Y0 - top_h - btm_h;

% create panel for selecting frame to plot:
resp_select_panel = uipanel('Parent',IC_fig,'BackgroundColor',clr,'Units','character','Position',[0 Y0-top_h X0 top_h],...
    'FontSize',12,'FontWeight','bold','TitlePosition','lefttop','Title','Select response to plot:');
resp_popup = uicontrol(resp_select_panel, 'Style', 'popupmenu', 'String',resp_label,'Value',r,...
    'Units','characters','Position',[2 1 70 1.5],'BackgroundColor','w',...
    'Callback',@RespSelectCallback);

IC_plot_panel = uipanel('Parent',IC_fig,'BackgroundColor',clr,'Units','character','Position',[0 btm_h X0 plot_h],...
    'FontSize',12,'FontWeight','bold','TitlePosition','lefttop','Title','Plot of influence coefficients:');
IC_plot_axes = axes('Parent',IC_plot_panel);

IC_menu_panel = uipanel('Parent',IC_fig,'BackgroundColor',clr,'Units','character','Position',[0 0 X0 btm_h]);

IC_frame_toggle = uicontrol(IC_menu_panel, 'Style','togglebutton','String','Frame Locations','Value',0,...
    'Units','characters','Position',[X0/6-toggle_w/2 0.5 toggle_w toggle_h],...
    'Callback',@FrameToggleCallback);
IC_IC_toggle = uicontrol(IC_menu_panel, 'Style','togglebutton','String','Influence Coefficients','Value',1,'Enable','inactive',...
    'BackgroundColor',.87*[1 1 1],'Units','characters','Position',[X0/2-toggle_w/2 0.5 toggle_w toggle_h]);
IC_exit_button = uicontrol(IC_menu_panel, 'Style','pushbutton','String','Close',...
    'Units','characters','Position',[X0*5/6-toggle_w/2 0.5 toggle_w toggle_h],...
    'Callback',@ExitCallback);


% extract building dimensions:
W = bldg_struct.d0(1);
L = bldg_struct.d0(2);
H = bldg_struct.d0(3);
R = bldg_struct.d0(4);

y = bldg_struct.frame_coords;
n_frames = size(y,1);
% plot frames to be analyzed with tributary areas:
color_list = {'b','r','g','c','m','y'};

% Terms for transformation from s-coordinates to x- and z-coordinates:
hyp = sqrt((W/2)^2+R^2); % hypotenuse of triangle formed by W/2 and R
s2x_0 = [0 0 W W]; % constant term for s -> x
s2x_1 = [0 W/(2*hyp) -W/(2*hyp) 0]; % linear term for s -> x
s2z_0 = [0 H H 0]; % constant term for s -> z
s2z_1 = [1 R/hyp R/hyp 1]; % linear term for s -> z

attach_pts = bldg_struct.attach_pts;

resp_names = bldg_struct.resp_names;
n_r = length(resp_names);
inf_coeff = bldg_struct.inf_coeff;

UpdateFramePlot;
UpdateICPlot;
set(IC_fig,'Visible','off');
uiwait(frame_fig);

% callback functions:

function FrameSelectCallback( src, event )
    f = get( frame_popup, 'Value');
    UpdateFramePlot;
end

function RespSelectCallback( src, event )
    r = get( resp_popup, 'Value');
    UpdateICPlot;
end

function UpdateFramePlot( src, event )
    axes(frame_plot_axes);
    cla reset;
    plot3([0 W W W/2 0 0],[0 0 0 0 0 0],[0 0 H H+R H 0],'k-', ...
        [0 W W W/2 0 0],[L L L L L L],[0 0 H H+R H 0],'k-', ...
        [0 0],[0 L],[0 0],'k-',[0 0],[0 L],[H H],'k-',...
        [W W],[0 L],[0 0],'k-',[W W],[0 L],[H H],'k-',...
        [W/2 W/2],[0 L],[H+R H+R],'k-');
    hold on;
    plot3([0 0 W/2 W W], y(f,1)*ones(1,5),[0 H H+R H 0],'b-','LineWidth',2);
    plot3([0 0 W/2 W W], y(f,3)*ones(1,5),[0 H H+R H 0],'g-','LineWidth',2);
    plot3([0 0 W/2 W W], y(f,2)*ones(1,5),[0 H H+R H 0],'r-','LineWidth',3);
    % loop through faces and plot girts/purlins:
    for j = 1:4
        % find s-coordinates for girts/purlins on current face:
        s_j = attach_pts(find(attach_pts(:,1)==j),2); 
        % transform to x- and z-coordinates:
        x_j = s2x_0(j) + s_j*s2x_1(j);
        z_j = s2z_0(j) + s_j*s2z_1(j);
        % plot each girt/purlin:
        for k = 1:length(s_j)
            plot3([x_j(k) x_j(k)], [y(f,1) y(f,3)] ,[z_j(k) z_j(k)],'r-','LineWidth',1);
        end
    end
    xlabel('x-axis'); ylabel('y-axis'); zlabel('z-axis');
    axis equal
    axis vis3d
    hold off;
end

function UpdateICPlot( src, event )
    axes(IC_plot_axes);
    cla reset;
    frame_vector_plot( inf_coeff(:,r), attach_pts, W, H, R, 1);
    title(['Influence coefficients for "' resp_names{r} '"']);
end

function FrameToggleCallback( src, event )
    set( frame_fig, 'Visible','on','Position',get(IC_fig,'Position'));
    set( IC_fig, 'Visible', 'off');
    set( IC_frame_toggle, 'Value', 0);
end

function ICToggleCallback( src, event )
    set( IC_fig, 'Visible','on','Position',get(frame_fig,'Position'));
    set( frame_fig, 'Visible', 'off');
    set( frame_IC_toggle, 'Value', 0);
end


function ExitCallback( src, event )
    close(IC_fig);
    close(frame_fig);
end

end

⌨️ 快捷键说明

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