資源簡介
利用Matlab編寫的兩點確定一條直線的程序,可計算其斜率等,利用了disp()函數,是我們更容易掌握!
代碼片段和文件信息
function?[ka1btype]=straight_line(AB)?%?輸入,AB兩點坐標
V=B-A
a=inf;
b=inf;
type=‘undefined‘;
if?A==B
????‘The?two?points?are?the?same‘
????return
end
if?V(1)==0?&&?V(2)==0
????disp(‘Enter?two?distinct?points?next?time‘)%disp()輸出
????return
end
if?V(1)==0
????type=‘vertical‘;
elseif?V(2)==0
????type=‘horizontal‘;
else
????type=‘oblique‘;
????slope=atan2(V(2)V(1));%atan2(??)求一個點對應的角度
????s=inv([A(1)?1;B(1)?1])*[A(2)?B(
- 上一篇:可見光通信matlab仿真代碼
- 下一篇:MATLAB 課設大作業 多按鍵
評論
共有 條評論