2.3.2剪力图和弯矩图方案备课讲稿
- 格式:ppt
- 大小:3.41 MB
- 文档页数:14
材料力学剪力图弯矩图绘制(有详细的程序)说明:输入变量:分段数组x分段点一般在集中力,集中力偶作用出和分布载荷的起末端。
载荷数组MPQ若梁上的外载荷总数为PN,则用PN行四列的数组MPQ储存载荷,数组MPQ第一列代表载荷的类型:1为集中力偶,2为集中力,3为分布载荷,第二列代表载荷的大小,第三列代表集中力,集中力偶或者分布载荷左端与简支梁左端的距离,第四列代表均匀载荷右端与简支梁左端的距离,当载荷为集中力或者集中力偶时,第四列为0.符号规定集中力和均匀载荷向下为正,向上为负,集中力偶顺时针为正,逆时针为负。
输出变量:内力数组XQM如果梁被分为NN-1段,则内力数组XQM为NN行,三列的数组,第一列代表梁的横截面的位置,第二列代表剪力,第三列代表弯矩。
剪力极值及位置QDXQDX是一个二行二列的数组,第一列代表极值所在的位置,第二列代表极值弯矩极值及位置MDXMDX是一个二行二列的数组,第一列代表极值所在的位置,第二列代表极值1.子程序1.1集中力偶对弯矩贡献的子函数QMM1.2集中力对剪力和弯矩贡献的子函数QMP1.3分布载荷对剪力和弯矩贡献的子函数QMQ1.4求剪力和弯矩极值的子函数MAX_MIN1.5绘制剪力图和弯矩图的子函数TU_QM2.计算分析程序2.1简支梁QMDJ2.2左端固定悬臂梁QMDXZ2.3右端固定悬臂梁QMDXY2.4左端外伸梁QMDWZ2.5右端外伸梁QMDWY2.6两端外伸梁QMDWL1.子程序1.1集中力偶对弯矩贡献的子函数QMMfunction MM=QMM(n,x1,a,M,MM)for j=1:nif x1(j)==an1=j;endendMM(n1:n)=MM(n1:n)+M;1.2集中力对剪力和弯矩贡献的子函数QMP function [QQ,MM]=QMP(n,x1,b,P,QQ,MM)for j=1:nif x1(j)==b;n1=j;endendQQ(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:nif x1(j)>cQQ(j)=QQ(j)-q*(x1(j)-c);MM(j)=MM(j)-0.5*q*(x1(j)-c)^2;endif x1(j)>dQQ(j)=QQ(j)+q*(x1(j)-d);MM(j)=MM(j)+0.5*q*(x1(j)-d)^2;endend1.4求剪力和弯矩极值的子函数MAX_MINfunction [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简支梁QMDJfunction XQM=QMDJ(x,MPQ)[n,m]=size(x);L=x(m);x1=[];for i=1:m-1x1=[x1,linspace(x(i),x(i+1),50)];endMM=zeros(size(x1));QQ=zeros(size(x1));[m,t]=size(MPQ);[t,n]=size(x1);for i=1:mswitch MPQ(i,1)case 1M=MPQ(i,2);a=MPQ(i,3);RA=-M/L;QQ=QQ+RA;MM=MM+RA*x1;if a>0 & a<LMM=QMM(n,x1,a,M,MM);endif a==0MM=MM+M;endcase 2P=MPQ(i,2);b=MPQ(i,3);RA=(L-b)*P/L;if b>0 & b<LQQ=QQ+RA;MM=MM+RA*x1;[QQ,MM]=QMP(n,x1,b,P,QQ,MM);endcase 3q=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);endend[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM);TU_QM(x1,QQ,MM);disp('梁的有限元分析结果')disp('位置-----------剪力----------弯矩')2.2左端固定悬臂梁QMDXZfunction XQM=QMDXZ(x,MPQ)[n,m]=size(x);L=x(m);x1=[];for i=1:m-1x1=[x1,linspace(x(i),x(i+1),50)];endMM=zeros(size(x1));QQ=zeros(size(x1));[PN,t]=size(MPQ);[t,n]=size(x1);for i=1:PNswitch MPQ(i,1)case 1M=MPQ(i,2);a=MPQ(i,3);if a>0 & a<LMM=MM-M;MM=QMM(n,x1,a,M,MM);endif a==LMM=MM-M;endcase 2P=MPQ(i,2);b=MPQ(i,3);RA=P;MA=-P*b;QQ=QQ+RA;MM=MM+RA*x1+MA;if b>0 & b<L[QQ,MM]=QMP(n,x1,b,P,QQ,MM);endcase 3q=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);endend[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM);TU_QM(x1,QQ,MM);disp('梁的有限元分析结果')disp('位置-----------剪力----------弯矩')2.3右端固定悬臂梁QMDXYfunction XQM=QMDXY(x,MPQ)[n,m]=size(x);L=x(m);x1=[];for i=1:m-1x1=[x1,linspace(x(i),x(i+1),50)];endMM=zeros(size(x1));QQ=zeros(size(x1));[PN,t]=size(MPQ);[t,n]=size(x1);for i=1:PNswitch MPQ(i,1)case 1M=MPQ(i,2);a=MPQ(i,3);if a==0MM=MM+M;endif a>0 & a<LMM=QMM(n,x1,a,M,MM);endcase 2P=MPQ(i,2);b=MPQ(i,3);if b==0QQ=QQ-PMM=MM-P*x1;endif b>0 & b<L[QQ,MM]=QMP(n,x1,b,P,QQ,MM);endcase 3q=MPQ(i,2);c=MPQ(i,3);d=MPQ(i,4);[QQ,MM]=QMQ(n,x1,c,d,q,QQ,MM);endend[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM);TU_QM(x1,QQ,MM);disp('梁的有限元分析结果')disp('位置-----------剪力----------弯矩')2.4左端外伸梁QMDWZfunction XQM=QMDWZ(x,L1,MPQ)[n,m]=size(x);L=x(m);x1=[];for i=1:m-1x1=[x1,linspace(x(i),x(i+1),50)];endMM=zeros(size(x1));QQ=zeros(size(x1));[PN,t]=size(MPQ);[t,n]=size(x1);for i=1:PNswitch MPQ(i,1)case 1M=MPQ(i,2);a=MPQ(i,3);if a>0 & a<LMM=QMM(n,x1,a,M,MM);endif a==0MM=MM+M;endcase 2P=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<L[QQ,MM]=QMP(n,x1,b,P,QQ,MM);endif b==0QQ=QQ-P;MM=MM-P*x1;endcase 3q=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);endend[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM);TU_QM(x1,QQ,MM);disp('梁的有限元分析结果')disp('位置-----------剪力----------弯矩')2.5右端外伸梁QMDWYfunction XQM=QMDWY(x,L1,MPQ)[n,m]=size(x);L=x(m);x1=[];for i=1:m-1x1=[x1,linspace(x(i),x(i+1),50)];endMM=zeros(size(x1));QQ=zeros(size(x1));[PN,t]=size(MPQ);[t,n]=size(x1);for i=1:PNswitch MPQ(i,1)case 1M=MPQ(i,2);a=MPQ(i,3);RA=-M/L1;RB=-RA;QQ=QQ+RA;MM=MM+x1*RA;if a>0 & a<LMM=QMM(n,x1,a,M,MM);endif a==0MM=MM+M;endcase 2P=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<L[QQ,MM]=QMP(n,x1,b,P,QQ,MM);endif b==0QQ=QQ-P;MM=MM-P*x1;endcase 3q=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);endend[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM);TU_QM(x1,QQ,MM);disp('梁的有限元分析结果')disp('位置-----------剪力----------弯矩')2.6两端外伸梁QMDWLfunction XQM=QMDWL(x,L1,L2,MPQ)[n,m]=size(x);L=x(m);x1=[];for i=1:m-1x1=[x1,linspace(x(i),x(i+1),50)];endMM=zeros(size(x1));QQ=zeros(size(x1));[PN,t]=size(MPQ);[t,n]=size(x1);for i=1:PNswitch MPQ(i,1)case 1M=MPQ(i,2);a=MPQ(i,3);RA=-M/(L2-L1);RB=-RA;if a>0 & a<LMM=QMM(n,x1,a,M,MM);endif a==0MM=MM+M;endcase 2P=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<L[QQ,MM]=QMP(n,x1,b,P,QQ,MM);endif b==0QQ=QQ-P;MM=MM-P*x1;endcase 3q=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);endend[QDX,MDX,XQM]=MAX_MIN(x1,QQ,MM);TU_QM(x1,QQ,MM);disp('梁的有限元分析结果')disp('位置-----------剪力----------弯矩')untitled.mfunction 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, GUIDA TA, 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 EDITgui_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});endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); elsegui_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 GUIDA TA) % varargin command line arguments to untitled (see V ARARGIN)% Choose default command line output for untitledhandles.output = hObject;% Update handles structureguidata(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 V ARARGOUT); % hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDA TA)% 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 GUIDA TA)% 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');endfunction 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 GUIDA TA)% 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');endfunction 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 GUIDA TA)% 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 GUIDA TA)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 handle to popupmenu1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDA TA)。