【運動學】基於matlab斜拋物體斜坡射程【含Matlab原始碼 980期】
阿新 • • 發佈:2021-06-19
一、簡介
說明了斜拋物體在斜坡上的射程計算方法,求出了最大射程與坡度關係,詳細討論了射程與坡度的關係。通過圖片顯示射程與射角的關係,最大射程與坡度的關係。
二、原始碼
%斜拋物體的射程 clear %清除變數 a1=-45; %最小坡度 alpha=a1:15:45; %斜坡仰角的度數 a=alpha*pi/180; %化為弧度數 n=length(a); %坡度的個數 theta=a1:5:90; %物體射角的度數 th=theta*pi/180; %物體射角的弧度數 [A,TH]=meshgrid(a,th); %仰角和射角矩陣 S=2*sin(TH-A).*cos(TH)./cos(A).^2; %射程矩陣(以水平最大射程為單位) S(S<0)=nan; %小於零的射程沒有意義(化為非數) figure %建立圖形視窗 %plot(theta,S,'LineWidth',2) %畫射程曲線族 plot(theta,S(:,1),'o-',theta,S(:,2),'d-',theta,S(:,3),'s-',... theta,S(:,4),'p-',theta,S(:,5),'h-',theta,S(:,6),'<-',... theta,S(:,7),'>-') %畫射程運動曲線族 grid on %加網格 h=legend([repmat('坡度:',n,1),num2str(alpha'),repmat('\circ',n,1)]);%插入坡度圖例 fs=16; %字型大小 set(h,'FontSize',fs-2) %放大圖例 thm=45+alpha/2; %最大射程的射角 sm=1./(1+sin(a)); %最大射程 text(thm,sm,num2str(sm',3),'FontSize',fs)%標記最大射程(保留3位) th0=a1*ones(1,n); %最大射程水平線的起點橫座標 hold on %保持影象
三、執行結果
四、備註
版本:2014a
完整程式碼或代寫加1564658423