plotline.m

来自「一本关于工程线性代数及其matlab编程方面的好书。」· M 代码 · 共 25 行

M
25
字号
% ATLAST65中的绘制直线方程子程序plotline
%
function plotline(a,b,c,s)
% PLOTLINE(a,b,c,s) plots the line ax + by = c 
% with axis set to [-s,s,-s,s].
% If the last input arguments is omitted, its
% default value is taken to be 5.
if nargin == 3
   s=5;
end
if (a == 0 & b == 0 & c ~= 0)
    error('No such line exists')
end
if  b == 0
    x = c/a;
    plot([x,x],[-s,s])
else
    y1 = (c+a*s)/b; y2 = (c-a*s)/b;
    plot([-s,s],[y1,y2])
end
axis([-s,s,-s,s])
ds = 0.2*s; 
set(gca,'XTick',[-s:ds:s])
set(gca,'YTick',[-s:ds:s])

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?