calfem工具箱MATLAB-图上未显示位移

calfem工具箱MATLAB-图上未显示位移,matlab,Matlab,你必须有calfem工具箱才能运行这段代码,所以我希望有些人能这样做 我已经从应用的udls中编写了一些代码来尝试显示位移,我使用了 uu=提取物(Edof,uu) 但是他们没有出现在我的身材上,有人知道为什么吗 addpath ([cd, '/fem']); % Constants E = 180e9; AB = 39.7e2; IB = 4413e4; AC = 110e2; IC = 9449e4; q1 = -15e3; w1 = -10e3; w2 = 5e3; LX1

你必须有calfem工具箱才能运行这段代码,所以我希望有些人能这样做

我已经从应用的
udls
中编写了一些代码来尝试显示位移,我使用了 uu=提取物(Edof,uu)

但是他们没有出现在我的身材上,有人知道为什么吗

addpath ([cd, '/fem']);

% Constants
E  = 180e9; 
AB = 39.7e2; IB = 4413e4; 
AC = 110e2;  IC = 9449e4;
q1 = -15e3;  w1 = -10e3; w2 = 5e3;

LX1 = 5; LX2 = 10; LX3 = 15; LX4 = 20; 
LY1 = 5; LY2 = 8;  LY3 = 9;

% Specify Node Coordinates
nodes = [  0,   0;
           0, LY1;
         LX1, LY2;
         LX2, LY1;
         LX2, LY3;
         LX3, LY2;
         LX4, LY1;
         LX4, 0];

% Specify Elements Nodes
conn = [1,2;
        2,3;
        2,4;
        3,4;
        3,5;
        4,5;
        4,6;
        4,7;
        5,6;
        6,7;
        7,8];

Nelem = length(conn);

% Initialise Structural Force/Stiffness Matrices
KK = zeros(8*3);
FF = zeros(8*3,1);

% Define Column and Beam Properties
Cprop = [E, AC, IC];
Bprop = [E, AB, IB];

% Initialise system properties
Edof  = zeros(Nelem, 1+6);
Ex    = zeros(Nelem, 2);
Ey    = zeros(Nelem, 2);
Eq    = zeros(Nelem, 2);
Eprop = zeros(Nelem,3);

for ii = 1:Nelem
    % Look up nodes of element
    node1 = conn(ii,1); node2 = conn(ii,2);

    % Work out dof based on node number
    dof1 = node1*3 + [-2,-1,0];
    dof2 = node2*3 + [-2,-1,0];

    % Assign to Edof
    Edof(ii,:) = [ii, dof1, dof2];

    % Look up coordinate based on node
    x1 = nodes(node1,1); y1=nodes(node1,2);
    x2 = nodes(node2,1); y2=nodes(node2,2);

    % Assign to Ex and Ey
    Ex(ii,:) = [x1,x2];
    Ey(ii,:) = [y1,y2];

    % Decide if the element is column or not
    if ii==1||11;
        Eprop(ii,:) = Cprop;
    elseif ii==2;
        Eprop(ii,:) = Bprop;
        Eq(ii,:) = [0.515*w1, 0.857*w1];
    elseif ii==5;
        Eprop(ii,:) = Bprop;
        Eq(ii,:) = [0.196*w1, 0.98*w1];  
    elseif ii==3||8;
        Eprop(ii,:) = Bprop;
        Eq(ii,:) = [0, q1];   
    elseif ii==9;
        Eprop(ii,:) = Bprop;
        Eq(ii,:) = [0.196*w2, 0.98*w2];
    elseif ii==10;
        Eprop(ii,:) = Bprop;
        Eq(ii,:) = [0.515*w1, 0.857*w1]; 
    else
        Eprop(ii,:) = Bprop;
    end

    % assemble system
    [KE,FE] = beam2e(Ex(ii,:), Ey(ii,:), Eprop(ii,:), Eq(ii,:));
    % Combine structural Stiffness forces
    [KK,FF] = assem(Edof(ii,:), KK, KE, FF,FE);
end

% Apply Boundary Conditions
bc = [1,0; 2,0; 3,0; 22,0; 23,0; 24,0];

% Solve System
[UU,RR] = solveq(KK,FF,bc);

figure(1)
% Undisplaced Shape
eldraw2(Ex,Ey,[1,1,1])
% Extract Local Displacements
uu = extract(Edof,UU);

% Plot Displaced Shape
scale = 1e2;
eldisp2(Ex,Ey, uu, [1,2,1], scale);

% Add Scale Bar for 10mm
pltscalb2(scale,[1e-2,6,6],[2]);

% Tidy up Graph
axis([-2,22,0,10])
axis equal
xlabel('X, m'); ylabel('Y, m')
title('Simple Portal Frame - Displacement')

在检查代码进行一些基本清理时,我注意到您编写了
if I==1 | | 11
。您知道这将始终计算为
true
,对吗?换句话说,其他情况无法联系到……如果i==8 | | i==11,则必须编写
,类似于其他情况。谢谢,我们了解到初始条件不正确的信息!你的问题解决了吗?