材料力学剪力图弯矩图绘制(有详细的程序)

材料力学剪力图弯矩图绘制(有详细的程序)

说明:

输入变量:

分段数组x

分段点一般在集中力,集中力偶作用出和分布载荷的起末端。

载荷数组MPQ

若梁上的外载荷总数为PN ,则用PN 行四列的数组MPQ 储存载荷,数组MPQ 第一列代表载荷的类型:1为集中力偶,2为集中力,3为分布载荷,第二列代表载荷的大小,第三列代表集中力,集中力偶或者分布载荷左端与简支梁左端的距离,第四列代表均匀载荷右端与简支梁左端的距离,当载荷为集中力或者集中力偶时,第四列为0.

符号规定

集中力和均匀载荷向下为正,向上为负,集中力偶顺时针为正,逆时针为负。

输出变量:

内力数组XQM

如果梁被分为NN-1段,则内力数组XQM 为NN 行,三列的数组,第一列代表梁的横截面的位置,第二列代表剪力,第三列代表弯矩。

剪力极值及位置QDX

QDX 是一个二行二列的数组,第一列代表极值所在的位置,第二列代表极值

弯矩极值及位置MDX

MDX 是一个二行二列的数组,第一列代表极值所在的位置,第二列代表极值

1. 子程序

1.1集中力偶对弯矩贡献的子函数QMM

1.2集中力对剪力和弯矩贡献的子函数QMP

1.3分布载荷对剪力和弯矩贡献的子函数QMQ

1.4求剪力和弯矩极值的子函数MAX_MIN

1.5绘制剪力图和弯矩图的子函数TU_QM

2. 计算分析程序

2.1简支梁QMDJ

2.2左端固定悬臂梁QMDXZ

2.3右端固定悬臂梁QMDXY

2.4左端外伸梁QMDWZ

2.5右端外伸梁QMDWY

2.6两端外伸梁QMDWL

1. 子程序

1.1集中力偶对弯矩贡献的子函数QMM

function MM=QMM(n,x1,a,M,MM)

for j=1:n

if x1(j)==a

n1=j;

end

end

MM(n1:n)=MM(n1:n)+M;

1.2集中力对剪力和弯矩贡献的子函数QMP function [QQ,MM]=QMP(n,x1,b,P,QQ,MM)

for j=1:n

if x1(j)==b;

n1=j;

end

end

QQ(n1:n)=QQ(n1:n)-P;

MM(n1:n)=MM(n1:n)-P*(x1(n1:n)-b);

1.3分布载荷对剪力和弯矩贡献的子函数QMQ function [QQ,MM]=QMQ(n,x1,c,d,q,QQ,MM) for j=1:n

if x1(j)>c

QQ(j)=QQ(j)-q*(x1(j)-c);

MM(j)=MM(j)-0.5*q*(x1(j)-c)^2;

end

if x1(j)>d

QQ(j)=QQ(j)+q*(x1(j)-d);

MM(j)=MM(j)+0.5*q*(x1(j)-d)^2;

end

end

1.4求剪力和弯矩极值的子函数MAX_MIN

function [QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM) XQM=[x1',QQ',MM'];

[Qmax,i]=max(QQ);

Q1=[Qmax,x1(i)];

[Qmin,i]=min(QQ);

Q2=[Qmin,x1(i)];

[Mmax,i]=max(MM);

M1=[Mmax,x1(i)];

[Mmin,i]=min(MM);

M2=[Mmin,x1(i)];

disp('剪力极值及位置')

QDX=[Q1;Q2]

disp('弯矩极值及位置')

MDX=[M1;M2]

t1=findobj(0,'Tag','text31');

str=num2str(Q1(1));

set(t1,'String',str);

t2=findobj(0,'Tag','text39');

str=num2str(Q1(2));

set(t2,'String',str);

t3=findobj(0,'Tag','text32');

str=num2str(Q2(1));

set(t3,'String',str);

t4=findobj(0,'Tag','text40');

str=num2str(Q2(2));

set(t4,'String',str);

m1=findobj(0,'Tag','text33');

str=num2str(M1(1));

set(m1,'String',str);

m2=findobj(0,'Tag','text41');

str=num2str(M1(2));

set(m2,'String',str);

m3=findobj(0,'Tag','text34');

str=num2str(M2(1));

set(m3,'String',str);

m4=findobj(0,'Tag','text42');

str=num2str(M2(2));

set(m4,'String',str);

1.5绘制剪力图和弯矩图的子函数TU_QM

function TU_QM(x1,QQ,MM)

h1=findobj(0,'Tag','axes1');

axes(h1);

plot(x1,QQ);

grid;

title('剪力图');

h2=findobj(0,'Tag','axes2');

axes(h2);

plot(x1,MM);

grid;

title('弯矩图');

2. 计算分析程序

2.1简支梁QMDJ

function XQM=QMDJ(x,MPQ)

[n,m]=size(x);

L=x(m);

x1=[];

for i=1:m-1

x1=[x1,linspace(x(i),x(i+1),50)];

end

MM=zeros(size(x1));

QQ=zeros(size(x1));

[m,t]=size(MPQ);

[t,n]=size(x1);

for i=1:m

switch MPQ(i,1)

case 1

M=MPQ(i,2);

a=MPQ(i,3);

RA=-M/L;

QQ=QQ+RA;

MM=MM+RA*x1;

if a>0 & a

MM=QMM(n,x1,a,M,MM);

end

if a==0

MM=MM+M;

end

case 2

P=MPQ(i,2);

b=MPQ(i,3);

RA=(L-b)*P/L;

if b>0 & b

QQ=QQ+RA;

MM=MM+RA*x1;

[QQ,MM]=QMP(n,x1,b,P,QQ,MM); end

case 3

q=MPQ(i,2);

c=MPQ(i,3);

d=MPQ(i,4);

RA=(L-0.5*(c+d))*q*(d-c)/L;

QQ=QQ+RA;

MM=MM+RA*x1+MA;

[QQ,MM]=QMQ(n,x1,c,d,q,QQ,MM);

end

end

[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM); TU_QM(x1,QQ,MM);

disp('梁的有限元分析结果')

disp('位置-----------剪力----------弯矩')

2.2左端固定悬臂梁QMDXZ

function XQM=QMDXZ(x,MPQ)

[n,m]=size(x);

L=x(m);

x1=[];

for i=1:m-1

x1=[x1,linspace(x(i),x(i+1),50)];

end

MM=zeros(size(x1));

QQ=zeros(size(x1));

[PN,t]=size(MPQ);

[t,n]=size(x1);

for i=1:PN

switch MPQ(i,1)

case 1

M=MPQ(i,2);

a=MPQ(i,3);

if a>0 & a

MM=MM-M;

MM=QMM(n,x1,a,M,MM);

end

if a==L

MM=MM-M;

end

case 2

P=MPQ(i,2);

b=MPQ(i,3);

RA=P;

MA=-P*b;

QQ=QQ+RA;

MM=MM+RA*x1+MA;

if b>0 & b

[QQ,MM]=QMP(n,x1,b,P,QQ,MM);

end

case 3

q=MPQ(i,2);

c=MPQ(i,3);

d=MPQ(i,4);

RA=q*(d-c);

MA=-0.5*q*(d-c)*(d+c);

QQ=QQ+RA;

MM=MM+RA*x1+MA;

[QQ,MM]=QMQ(n,x1,c,d,q,QQ,MM);

end

end

[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM); TU_QM(x1,QQ,MM);

disp('梁的有限元分析结果')

disp('位置-----------剪力----------弯矩')

2.3右端固定悬臂梁QMDXY

function XQM=QMDXY(x,MPQ)

[n,m]=size(x);

L=x(m);

x1=[];

for i=1:m-1

x1=[x1,linspace(x(i),x(i+1),50)];

end

MM=zeros(size(x1));

QQ=zeros(size(x1));

[PN,t]=size(MPQ);

[t,n]=size(x1);

for i=1:PN

switch MPQ(i,1)

case 1

M=MPQ(i,2);

a=MPQ(i,3);

if a==0

MM=MM+M;

end

if a>0 & a

MM=QMM(n,x1,a,M,MM);

end

case 2

P=MPQ(i,2);

b=MPQ(i,3);

if b==0

QQ=QQ-P

MM=MM-P*x1;

end

if b>0 & b

[QQ,MM]=QMP(n,x1,b,P,QQ,MM);

end

case 3

q=MPQ(i,2);

c=MPQ(i,3);

d=MPQ(i,4);

[QQ,MM]=QMQ(n,x1,c,d,q,QQ,MM);

end

end

[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM); TU_QM(x1,QQ,MM);

disp('梁的有限元分析结果')

disp('位置-----------剪力----------弯矩')

2.4左端外伸梁QMDWZ

function XQM=QMDWZ(x,L1,MPQ)

[n,m]=size(x);

L=x(m);

x1=[];

for i=1:m-1

x1=[x1,linspace(x(i),x(i+1),50)]; end

MM=zeros(size(x1));

QQ=zeros(size(x1));

[PN,t]=size(MPQ);

[t,n]=size(x1);

for i=1:PN

switch MPQ(i,1)

case 1

M=MPQ(i,2);

a=MPQ(i,3);

if a>0 & a

MM=QMM(n,x1,a,M,MM);

end

if a==0

MM=MM+M;

end

case 2

P=MPQ(i,2);

b=MPQ(i,3);

RA=P*(L-b)/(L-L1);

[QQ,MM]=QMP(n,x1,L1,-RA,QQ,MM);

if b>0 & b

[QQ,MM]=QMP(n,x1,b,P,QQ,MM);

end

if b==0

QQ=QQ-P;

MM=MM-P*x1;

end

case 3

q=MPQ(i,2);

c=MPQ(i,3);

d=MPQ(i,4);

b=(c+d)*0.5;

P=(d-c)*q;

RA=P*(L-b)/(L-L1);

[QQ,MM]=QMP(n,x1,L1,-RA,QQ,MM);

[QQ,MM]=QMQ(n,x1,c,d,q,QQ,MM);

end

end

[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM);

TU_QM(x1,QQ,MM);

disp('梁的有限元分析结果')

disp('位置-----------剪力----------弯矩')

2.5右端外伸梁QMDWY

function XQM=QMDWY(x,L1,MPQ)

[n,m]=size(x);

L=x(m);

x1=[];

for i=1:m-1

x1=[x1,linspace(x(i),x(i+1),50)]; end

MM=zeros(size(x1));

QQ=zeros(size(x1));

[PN,t]=size(MPQ);

[t,n]=size(x1);

for i=1:PN

switch MPQ(i,1)

case 1

M=MPQ(i,2);

a=MPQ(i,3);

RA=-M/L1;

RB=-RA;

QQ=QQ+RA;

MM=MM+x1*RA;

if a>0 & a

MM=QMM(n,x1,a,M,MM);

end

if a==0

MM=MM+M;

end

case 2

P=MPQ(i,2);

b=MPQ(i,3);

RA=P*(L1-b)/L1;

RB=P*b/L1;

QQ=QQ+RA;

MM=MM+x1*RA;

[QQ,MM]=QMP(n,x1,L1,-RB,QQ,MM);

if b>0 & b

[QQ,MM]=QMP(n,x1,b,P,QQ,MM);

end

if b==0

QQ=QQ-P;

MM=MM-P*x1;

end

case 3

q=MPQ(i,2);

c=MPQ(i,3);

d=MPQ(i,4);

b=(c+d)*0.5;

P=(d-c)*q;

RA=P*(L1-b)/L1;

RB=P*b/L1;

QQ=QQ+RA;

MM=MM+x1*RA;

[QQ,MM]=QMP(n,x1,L1,-RB,QQ,MM);

[QQ,MM]=QMQ(n,x1,c,d,q,QQ,MM);

end

end

[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM);

TU_QM(x1,QQ,MM);

disp('梁的有限元分析结果')

disp('位置-----------剪力----------弯矩')

2.6两端外伸梁QMDWL

function XQM=QMDWL(x,L1,L2,MPQ)

[n,m]=size(x);

L=x(m);

x1=[];

for i=1:m-1

x1=[x1,linspace(x(i),x(i+1),50)]; end

MM=zeros(size(x1));

QQ=zeros(size(x1));

[PN,t]=size(MPQ);

[t,n]=size(x1);

for i=1:PN

switch MPQ(i,1)

case 1

M=MPQ(i,2);

a=MPQ(i,3);

RA=-M/(L2-L1);

RB=-RA;

if a>0 & a

MM=QMM(n,x1,a,M,MM); end

if a==0

MM=MM+M;

end

case 2

P=MPQ(i,2);

b=MPQ(i,3);

LL=L2-L1;

bb=b-L1;

RA=P*(LL-bb)/LL;

RB=P*bb/LL;

[QQ,MM]=QMP(n,x1,L1,-RA,QQ,MM);

[QQ,MM]=QMP(n,x1,L2,-RB,QQ,MM); if b>0 & b

[QQ,MM]=QMP(n,x1,b,P,QQ,MM); end

if b==0

QQ=QQ-P;

MM=MM-P*x1;

end

case 3

q=MPQ(i,2);

c=MPQ(i,3);

d=MPQ(i,4);

b=(c+d)*0.5;

P=(d-c)*q;

LL=L2-L1;

bb=b-L1;

RA=P*(LL-bb)/LL;

RB=P*bb/LL;

[QQ,MM]=QMP(n,x1,L1,-RA,QQ,MM);

[QQ,MM]=QMP(n,x1,L2,-RB,QQ,MM);

[QQ,MM]=QMQ(n,x1,c,d,q,QQ,MM);

end

end

[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM);

TU_QM(x1,QQ,MM);

disp('梁的有限元分析结果')

disp('位置-----------剪力----------弯矩')

untitled.m

function varargout = untitled(varargin)

% UNTITLED M-file for untitled.fig

% UNTITLED, by itself, creates a new UNTITLED or raises the existing

% singleton*.

%

% H = UNTITLED returns the handle to a new UNTITLED or the handle to

% the existing singleton*.

%

% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local

% function named CALLBACK in UNTITLED.M with the given input arguments. %

% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the

% existing singleton*. Starting from the left, property value pairs are

% applied to the GUI before untitled_OpeningFunction gets called. An

% unrecognized property name or invalid value makes property application

% stop. All inputs are passed to untitled_OpeningFcn via varargin.

%

% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)".

%

% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help untitled

% Last Modified by GUIDE v2.5 03-Jun-2008 23:12:06

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ...

'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @untitled_OpeningFcn, ...

'gui_OutputFcn', @untitled_OutputFcn, ...

'gui_LayoutFcn', [] , ...

'gui_Callback', []);

if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1});

end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

else

gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT

% --- Executes just before untitled is made visible.

function untitled_OpeningFcn(hObject, eventdata, handles, varargin)

% This function has no output args, see OutputFcn.

% hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% varargin command line arguments to untitled (see VARARGIN)

% Choose default command line output for untitled

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% UIWAIT makes untitled wait for user response (see UIRESUME)

% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = untitled_OutputFcn(hObject, eventdata, handles)

% varargout cell array for returning output args (see VARARGOUT);

% hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure

varargout{1} = handles.output;

function edit2_Callback(hObject, eventdata, handles)

% hObject handle to edit2 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text

% str2double(get(hObject,'String')) returns contents of edit2 as a double

% --- Executes during object creation, after setting all properties.

function edit2_CreateFcn(hObject, eventdata, handles)

% hObject handle to edit2 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');

end

function edit3_Callback(hObject, eventdata, handles)

% hObject handle to edit3 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text

% str2double(get(hObject,'String')) returns contents of edit3 as a double

% --- Executes during object creation, after setting all properties.

function edit3_CreateFcn(hObject, eventdata, handles)

% hObject handle to edit3 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');

end

function edit4_Callback(hObject, eventdata, handles)

% hObject handle to edit4 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit4 as text

% str2double(get(hObject,'String')) returns contents of edit4 as a double

% --- Executes during object creation, after setting all properties.

function edit4_CreateFcn(hObject, eventdata, handles)

% hObject handle to edit4 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');

end

% --- Executes on selection change in popupmenu1.

function popupmenu1_Callback(hObject, eventdata, handles)

% hObject handle to popupmenu1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array

% contents{get(hObject,'Value')} returns selected item from popupmenu1

% --- Executes during object creation, after setting all properties.

function popupmenu1_CreateFcn(hObject, eventdata, handles)

% hObject handle to popupmenu1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');

end

% --- Executes on button press in pushbutton3.

function pushbutton3_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton3 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

x=str2num(get(handles.edit2,'string'));

MPQ=str2num(get(handles.edit3,'string'));

L=str2num(get(handles.edit4,'string'));

L1=L(1);

L2=L(2);

val=get(handles.popupmenu1,'Value');

str=get(handles.popupmenu1,'String');

switch str{val}

case '简支梁'

QMDJ(x,MPQ)

case '左端固定悬臂梁'

QMDXZ(x,MPQ)

case '右端固定悬臂梁'

QMDXY(x,MPQ)

case '左端外伸梁'

QMDWZ(x,L1,MPQ)

case '右端外伸梁'

QMDWY(x,L1,MPQ)

case '两端外伸梁'

QMDWL(x,L1,L2,MPQ)

end

% --- Executes on button press in pushbutton4.

function pushbutton4_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton4 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) close all

% --- Executes on key press over popupmenu1 with no controls selected. function popupmenu1_KeyPressFcn(hObject, eventdata, handles) % hObject

% eventdata

% handles

handle to popupmenu1 (see GCBO) reserved - to be defined in a future version of MATLAB structure with handles and user data (see GUIDATA)

材料力学剪力图弯矩图绘制(有详细的程序)

说明:

输入变量:

分段数组x

分段点一般在集中力,集中力偶作用出和分布载荷的起末端。

载荷数组MPQ

若梁上的外载荷总数为PN ,则用PN 行四列的数组MPQ 储存载荷,数组MPQ 第一列代表载荷的类型:1为集中力偶,2为集中力,3为分布载荷,第二列代表载荷的大小,第三列代表集中力,集中力偶或者分布载荷左端与简支梁左端的距离,第四列代表均匀载荷右端与简支梁左端的距离,当载荷为集中力或者集中力偶时,第四列为0.

符号规定

集中力和均匀载荷向下为正,向上为负,集中力偶顺时针为正,逆时针为负。

输出变量:

内力数组XQM

如果梁被分为NN-1段,则内力数组XQM 为NN 行,三列的数组,第一列代表梁的横截面的位置,第二列代表剪力,第三列代表弯矩。

剪力极值及位置QDX

QDX 是一个二行二列的数组,第一列代表极值所在的位置,第二列代表极值

弯矩极值及位置MDX

MDX 是一个二行二列的数组,第一列代表极值所在的位置,第二列代表极值

1. 子程序

1.1集中力偶对弯矩贡献的子函数QMM

1.2集中力对剪力和弯矩贡献的子函数QMP

1.3分布载荷对剪力和弯矩贡献的子函数QMQ

1.4求剪力和弯矩极值的子函数MAX_MIN

1.5绘制剪力图和弯矩图的子函数TU_QM

2. 计算分析程序

2.1简支梁QMDJ

2.2左端固定悬臂梁QMDXZ

2.3右端固定悬臂梁QMDXY

2.4左端外伸梁QMDWZ

2.5右端外伸梁QMDWY

2.6两端外伸梁QMDWL

1. 子程序

1.1集中力偶对弯矩贡献的子函数QMM

function MM=QMM(n,x1,a,M,MM)

for j=1:n

if x1(j)==a

n1=j;

end

end

MM(n1:n)=MM(n1:n)+M;

1.2集中力对剪力和弯矩贡献的子函数QMP function [QQ,MM]=QMP(n,x1,b,P,QQ,MM)

for j=1:n

if x1(j)==b;

n1=j;

end

end

QQ(n1:n)=QQ(n1:n)-P;

MM(n1:n)=MM(n1:n)-P*(x1(n1:n)-b);

1.3分布载荷对剪力和弯矩贡献的子函数QMQ function [QQ,MM]=QMQ(n,x1,c,d,q,QQ,MM) for j=1:n

if x1(j)>c

QQ(j)=QQ(j)-q*(x1(j)-c);

MM(j)=MM(j)-0.5*q*(x1(j)-c)^2;

end

if x1(j)>d

QQ(j)=QQ(j)+q*(x1(j)-d);

MM(j)=MM(j)+0.5*q*(x1(j)-d)^2;

end

end

1.4求剪力和弯矩极值的子函数MAX_MIN

function [QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM) XQM=[x1',QQ',MM'];

[Qmax,i]=max(QQ);

Q1=[Qmax,x1(i)];

[Qmin,i]=min(QQ);

Q2=[Qmin,x1(i)];

[Mmax,i]=max(MM);

M1=[Mmax,x1(i)];

[Mmin,i]=min(MM);

M2=[Mmin,x1(i)];

disp('剪力极值及位置')

QDX=[Q1;Q2]

disp('弯矩极值及位置')

MDX=[M1;M2]

t1=findobj(0,'Tag','text31');

str=num2str(Q1(1));

set(t1,'String',str);

t2=findobj(0,'Tag','text39');

str=num2str(Q1(2));

set(t2,'String',str);

t3=findobj(0,'Tag','text32');

str=num2str(Q2(1));

set(t3,'String',str);

t4=findobj(0,'Tag','text40');

str=num2str(Q2(2));

set(t4,'String',str);

m1=findobj(0,'Tag','text33');

str=num2str(M1(1));

set(m1,'String',str);

m2=findobj(0,'Tag','text41');

str=num2str(M1(2));

set(m2,'String',str);

m3=findobj(0,'Tag','text34');

str=num2str(M2(1));

set(m3,'String',str);

m4=findobj(0,'Tag','text42');

str=num2str(M2(2));

set(m4,'String',str);

1.5绘制剪力图和弯矩图的子函数TU_QM

function TU_QM(x1,QQ,MM)

h1=findobj(0,'Tag','axes1');

axes(h1);

plot(x1,QQ);

grid;

title('剪力图');

h2=findobj(0,'Tag','axes2');

axes(h2);

plot(x1,MM);

grid;

title('弯矩图');

2. 计算分析程序

2.1简支梁QMDJ

function XQM=QMDJ(x,MPQ)

[n,m]=size(x);

L=x(m);

x1=[];

for i=1:m-1

x1=[x1,linspace(x(i),x(i+1),50)];

end

MM=zeros(size(x1));

QQ=zeros(size(x1));

[m,t]=size(MPQ);

[t,n]=size(x1);

for i=1:m

switch MPQ(i,1)

case 1

M=MPQ(i,2);

a=MPQ(i,3);

RA=-M/L;

QQ=QQ+RA;

MM=MM+RA*x1;

if a>0 & a

MM=QMM(n,x1,a,M,MM);

end

if a==0

MM=MM+M;

end

case 2

P=MPQ(i,2);

b=MPQ(i,3);

RA=(L-b)*P/L;

if b>0 & b

QQ=QQ+RA;

MM=MM+RA*x1;

[QQ,MM]=QMP(n,x1,b,P,QQ,MM); end

case 3

q=MPQ(i,2);

c=MPQ(i,3);

d=MPQ(i,4);

RA=(L-0.5*(c+d))*q*(d-c)/L;

QQ=QQ+RA;

MM=MM+RA*x1+MA;

[QQ,MM]=QMQ(n,x1,c,d,q,QQ,MM);

end

end

[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM); TU_QM(x1,QQ,MM);

disp('梁的有限元分析结果')

disp('位置-----------剪力----------弯矩')

2.2左端固定悬臂梁QMDXZ

function XQM=QMDXZ(x,MPQ)

[n,m]=size(x);

L=x(m);

x1=[];

for i=1:m-1

x1=[x1,linspace(x(i),x(i+1),50)];

end

MM=zeros(size(x1));

QQ=zeros(size(x1));

[PN,t]=size(MPQ);

[t,n]=size(x1);

for i=1:PN

switch MPQ(i,1)

case 1

M=MPQ(i,2);

a=MPQ(i,3);

if a>0 & a

MM=MM-M;

MM=QMM(n,x1,a,M,MM);

end

if a==L

MM=MM-M;

end

case 2

P=MPQ(i,2);

b=MPQ(i,3);

RA=P;

MA=-P*b;

QQ=QQ+RA;

MM=MM+RA*x1+MA;

if b>0 & b

[QQ,MM]=QMP(n,x1,b,P,QQ,MM);

end

case 3

q=MPQ(i,2);

c=MPQ(i,3);

d=MPQ(i,4);

RA=q*(d-c);

MA=-0.5*q*(d-c)*(d+c);

QQ=QQ+RA;

MM=MM+RA*x1+MA;

[QQ,MM]=QMQ(n,x1,c,d,q,QQ,MM);

end

end

[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM); TU_QM(x1,QQ,MM);

disp('梁的有限元分析结果')

disp('位置-----------剪力----------弯矩')

2.3右端固定悬臂梁QMDXY

function XQM=QMDXY(x,MPQ)

[n,m]=size(x);

L=x(m);

x1=[];

for i=1:m-1

x1=[x1,linspace(x(i),x(i+1),50)];

end

MM=zeros(size(x1));

QQ=zeros(size(x1));

[PN,t]=size(MPQ);

[t,n]=size(x1);

for i=1:PN

switch MPQ(i,1)

case 1

M=MPQ(i,2);

a=MPQ(i,3);

if a==0

MM=MM+M;

end

if a>0 & a

MM=QMM(n,x1,a,M,MM);

end

case 2

P=MPQ(i,2);

b=MPQ(i,3);

if b==0

QQ=QQ-P

MM=MM-P*x1;

end

if b>0 & b

[QQ,MM]=QMP(n,x1,b,P,QQ,MM);

end

case 3

q=MPQ(i,2);

c=MPQ(i,3);

d=MPQ(i,4);

[QQ,MM]=QMQ(n,x1,c,d,q,QQ,MM);

end

end

[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM); TU_QM(x1,QQ,MM);

disp('梁的有限元分析结果')

disp('位置-----------剪力----------弯矩')

2.4左端外伸梁QMDWZ

function XQM=QMDWZ(x,L1,MPQ)

[n,m]=size(x);

L=x(m);

x1=[];

for i=1:m-1

x1=[x1,linspace(x(i),x(i+1),50)]; end

MM=zeros(size(x1));

QQ=zeros(size(x1));

[PN,t]=size(MPQ);

[t,n]=size(x1);

for i=1:PN

switch MPQ(i,1)

case 1

M=MPQ(i,2);

a=MPQ(i,3);

if a>0 & a

MM=QMM(n,x1,a,M,MM);

end

if a==0

MM=MM+M;

end

case 2

P=MPQ(i,2);

b=MPQ(i,3);

RA=P*(L-b)/(L-L1);

[QQ,MM]=QMP(n,x1,L1,-RA,QQ,MM);

if b>0 & b

[QQ,MM]=QMP(n,x1,b,P,QQ,MM);

end

if b==0

QQ=QQ-P;

MM=MM-P*x1;

end

case 3

q=MPQ(i,2);

c=MPQ(i,3);

d=MPQ(i,4);

b=(c+d)*0.5;

P=(d-c)*q;

RA=P*(L-b)/(L-L1);

[QQ,MM]=QMP(n,x1,L1,-RA,QQ,MM);

[QQ,MM]=QMQ(n,x1,c,d,q,QQ,MM);

end

end

[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM);

TU_QM(x1,QQ,MM);

disp('梁的有限元分析结果')

disp('位置-----------剪力----------弯矩')

2.5右端外伸梁QMDWY

function XQM=QMDWY(x,L1,MPQ)

[n,m]=size(x);

L=x(m);

x1=[];

for i=1:m-1

x1=[x1,linspace(x(i),x(i+1),50)]; end

MM=zeros(size(x1));

QQ=zeros(size(x1));

[PN,t]=size(MPQ);

[t,n]=size(x1);

for i=1:PN

switch MPQ(i,1)

case 1

M=MPQ(i,2);

a=MPQ(i,3);

RA=-M/L1;

RB=-RA;

QQ=QQ+RA;

MM=MM+x1*RA;

if a>0 & a

MM=QMM(n,x1,a,M,MM);

end

if a==0

MM=MM+M;

end

case 2

P=MPQ(i,2);

b=MPQ(i,3);

RA=P*(L1-b)/L1;

RB=P*b/L1;

QQ=QQ+RA;

MM=MM+x1*RA;

[QQ,MM]=QMP(n,x1,L1,-RB,QQ,MM);

if b>0 & b

[QQ,MM]=QMP(n,x1,b,P,QQ,MM);

end

if b==0

QQ=QQ-P;

MM=MM-P*x1;

end

case 3

q=MPQ(i,2);

c=MPQ(i,3);

d=MPQ(i,4);

b=(c+d)*0.5;

P=(d-c)*q;

RA=P*(L1-b)/L1;

RB=P*b/L1;

QQ=QQ+RA;

MM=MM+x1*RA;

[QQ,MM]=QMP(n,x1,L1,-RB,QQ,MM);

[QQ,MM]=QMQ(n,x1,c,d,q,QQ,MM);

end

end

[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM);

TU_QM(x1,QQ,MM);

disp('梁的有限元分析结果')

disp('位置-----------剪力----------弯矩')

2.6两端外伸梁QMDWL

function XQM=QMDWL(x,L1,L2,MPQ)

[n,m]=size(x);

L=x(m);

x1=[];

for i=1:m-1

x1=[x1,linspace(x(i),x(i+1),50)]; end

MM=zeros(size(x1));

QQ=zeros(size(x1));

[PN,t]=size(MPQ);

[t,n]=size(x1);

for i=1:PN

switch MPQ(i,1)

case 1

M=MPQ(i,2);

a=MPQ(i,3);

RA=-M/(L2-L1);

RB=-RA;

if a>0 & a

MM=QMM(n,x1,a,M,MM); end

if a==0

MM=MM+M;

end

case 2

P=MPQ(i,2);

b=MPQ(i,3);

LL=L2-L1;

bb=b-L1;

RA=P*(LL-bb)/LL;

RB=P*bb/LL;

[QQ,MM]=QMP(n,x1,L1,-RA,QQ,MM);

[QQ,MM]=QMP(n,x1,L2,-RB,QQ,MM); if b>0 & b

[QQ,MM]=QMP(n,x1,b,P,QQ,MM); end

if b==0

QQ=QQ-P;

MM=MM-P*x1;

end

case 3

q=MPQ(i,2);

c=MPQ(i,3);

d=MPQ(i,4);

b=(c+d)*0.5;

P=(d-c)*q;

LL=L2-L1;

bb=b-L1;

RA=P*(LL-bb)/LL;

RB=P*bb/LL;

[QQ,MM]=QMP(n,x1,L1,-RA,QQ,MM);

[QQ,MM]=QMP(n,x1,L2,-RB,QQ,MM);

[QQ,MM]=QMQ(n,x1,c,d,q,QQ,MM);

end

end

[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM);

TU_QM(x1,QQ,MM);

disp('梁的有限元分析结果')

disp('位置-----------剪力----------弯矩')

untitled.m

function varargout = untitled(varargin)

% UNTITLED M-file for untitled.fig

% UNTITLED, by itself, creates a new UNTITLED or raises the existing

% singleton*.

%

% H = UNTITLED returns the handle to a new UNTITLED or the handle to

% the existing singleton*.

%

% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local

% function named CALLBACK in UNTITLED.M with the given input arguments. %

% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the

% existing singleton*. Starting from the left, property value pairs are

% applied to the GUI before untitled_OpeningFunction gets called. An

% unrecognized property name or invalid value makes property application

% stop. All inputs are passed to untitled_OpeningFcn via varargin.

%

% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)".

%

% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help untitled

% Last Modified by GUIDE v2.5 03-Jun-2008 23:12:06

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ...

'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @untitled_OpeningFcn, ...

'gui_OutputFcn', @untitled_OutputFcn, ...

'gui_LayoutFcn', [] , ...

'gui_Callback', []);

if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1});

end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

else

gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT

% --- Executes just before untitled is made visible.

function untitled_OpeningFcn(hObject, eventdata, handles, varargin)

% This function has no output args, see OutputFcn.

% hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% varargin command line arguments to untitled (see VARARGIN)

% Choose default command line output for untitled

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% UIWAIT makes untitled wait for user response (see UIRESUME)

% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = untitled_OutputFcn(hObject, eventdata, handles)

% varargout cell array for returning output args (see VARARGOUT);

% hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure

varargout{1} = handles.output;

function edit2_Callback(hObject, eventdata, handles)

% hObject handle to edit2 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text

% str2double(get(hObject,'String')) returns contents of edit2 as a double

% --- Executes during object creation, after setting all properties.

function edit2_CreateFcn(hObject, eventdata, handles)

% hObject handle to edit2 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');

end

function edit3_Callback(hObject, eventdata, handles)

% hObject handle to edit3 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text

% str2double(get(hObject,'String')) returns contents of edit3 as a double

% --- Executes during object creation, after setting all properties.

function edit3_CreateFcn(hObject, eventdata, handles)

% hObject handle to edit3 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');

end

function edit4_Callback(hObject, eventdata, handles)

% hObject handle to edit4 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit4 as text

% str2double(get(hObject,'String')) returns contents of edit4 as a double

% --- Executes during object creation, after setting all properties.

function edit4_CreateFcn(hObject, eventdata, handles)

% hObject handle to edit4 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');

end

% --- Executes on selection change in popupmenu1.

function popupmenu1_Callback(hObject, eventdata, handles)

% hObject handle to popupmenu1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array

% contents{get(hObject,'Value')} returns selected item from popupmenu1

% --- Executes during object creation, after setting all properties.

function popupmenu1_CreateFcn(hObject, eventdata, handles)

% hObject handle to popupmenu1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');

end

% --- Executes on button press in pushbutton3.

function pushbutton3_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton3 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

x=str2num(get(handles.edit2,'string'));

MPQ=str2num(get(handles.edit3,'string'));

L=str2num(get(handles.edit4,'string'));

L1=L(1);

L2=L(2);

val=get(handles.popupmenu1,'Value');

str=get(handles.popupmenu1,'String');

switch str{val}

case '简支梁'

QMDJ(x,MPQ)

case '左端固定悬臂梁'

QMDXZ(x,MPQ)

case '右端固定悬臂梁'

QMDXY(x,MPQ)

case '左端外伸梁'

QMDWZ(x,L1,MPQ)

case '右端外伸梁'

QMDWY(x,L1,MPQ)

case '两端外伸梁'

QMDWL(x,L1,L2,MPQ)

end

% --- Executes on button press in pushbutton4.

function pushbutton4_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton4 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) close all

% --- Executes on key press over popupmenu1 with no controls selected. function popupmenu1_KeyPressFcn(hObject, eventdata, handles) % hObject

% eventdata

% handles

handle to popupmenu1 (see GCBO) reserved - to be defined in a future version of MATLAB structure with handles and user data (see GUIDATA)


相关文章

  • [材料力学]中剪力图和弯矩图的快易绘图法
  • <材料力学>中剪力图和弯矩图的快易绘图法 [摘 要]在<材料力学>中,绘制平面弯曲梁的剪力图和弯矩图是"直梁的弯曲"一章中的重点和难点,传统的规律绘图法用到的一次函数. 二次函数和导数等相关知识, ...查看


  • 材料力学课程设计
  • 设计题目: 传动轴的静强度,变形及疲劳强度计算 学学姓 院:交通学院号:44110122名:陈思吉 峰 指导教师:李 2013.10.17 目录 一设计目的----------------2二设计题目----------------2三设计 ...查看


  • MATLAB在工程力学教学中的应用
  • 摘 要 针对传统工程力学教学中,较为复杂的计算和作图不便于学生全面理解学习内容.且占用过多课堂教学时间的问题,将计算和作图交给计算机,运用MATLAB数学计算软件编制程序来解决,大大提高课堂教学效率,提升了学生的学习效率,加深了学生对所学内 ...查看


  • 梁的内力计算 (1)
  • 第四章 梁的内力 第一节 工程实际中的受弯杆 受弯杆件是工程实际中最常见的一种变形杆,通常把以弯曲为主的杆件称为梁.图4-1中列举了例子并画出了它们的计算简图.如图(a )表示的是房屋建筑中的板.梁.柱结构,其中支撑楼板的大梁AB 受到由楼 ...查看


  • 有限元课程设计 1
  • 沈阳理工大学课程设计专用纸 平面梁结构的内力计算 一:问题描述及数学建模 一个外伸梁的结构如下图所示,其中m=10KN.m,q=2KN/m,F=2KN.其中梁宽B=0.1m,梁高H=0.2m,梁长L=8m.对该梁进行分析,画出弯矩图和剪力图 ...查看


  • 结构力学答案02
  • 哈尔滨工业大学远程教育学院 2006年秋季学期 结构力学 答案(开卷,时间:120分钟) (所有答案必须写在答题纸上) 一. 是非题(每题4分共20分,正确的标〇,错误的标) 1. 所谓超静定结构就是没有多余约束的几何不变体系(  ) ...查看


  • 建筑力学作业答案
  • 第一章 静力学基本知识 小结 1) 静力学的基本概念 (a)平衡物体相对于地球保持静止或作匀速直线运动的状态. (b)刚体是在任何外力作用下,大小和形状保持不变的物体. (c)力是物体间相互的机械作用,这种作用使物体的运动状态改变(外效应) ...查看


  • 毕业论文办公楼框架结构设计
  • 题 目 毕 业 论 文 (设 计) 英文题目 院 系 土木工程与城市建设学院 专 业 姓 名 黄 海 年 级 2010级土A1014 指导教师 戴 嘉 兴 二零一四年六月 摘 要 本工程为华宇办公楼的结构设计,采用混凝土框架结构, 该办公楼 ...查看


  • 2007年第二届中南地区结构力学竞赛试题及答案
  • 第二届(2007年)"结构力学竞赛试题" 一.(14分)试分析图示刚架,绘制其弯矩图和剪力图. 二.(12分)试作图示体系的几何组成分析(说明理由).并求指定杆1和2的轴力FN1和FN2. FP 2mm 题二图 题一图 ...查看


热门内容