闲话不说,直接上代码与图的效果!

matlab画直线,指定斜率与x坐标范围

 


AngleD=59; %[-90 90]
c=20:80;
centralPoint=[50 50]';
image=zeros(100,100);
image(25:74,25:74)=ceil(abs(rand(50,50).*10));


if abs(AngleD)==90,
    fprintf(1,'no single line for the x area\n');
elseif AngleD==0,
    r=centralPoint(1).*ones(size(c,2),1);
else
    k=tand(AngleD);
    b=centralPoint(1)-k*centralPoint(2);
    r=k.*c+b;
end

imagesc(image);
hold on
plot(c,r,'r-');
hold off;
colormap gray;
axis equal

 

相关文章:

  • 2022-12-23
  • 2021-11-11
  • 2021-11-19
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2021-12-09
猜你喜欢
  • 2021-12-06
  • 2021-08-19
  • 2022-12-23
  • 2021-12-06
  • 2021-04-30
  • 2022-12-23
相关资源
相似解决方案