分享好友 编程语言首页 频道列表

matlab实现贝塞尔曲线绘图pdf查看

matlab  2023-02-09 07:340

贝塞尔曲线绘图方法:

%Program 3.7 Freehand Draw Program Using Bezier Splines
%Click in Matlab figure window to locate first point, and click
% three more times to specify 2 control points and the next
% spline point. Continue with groups of 3 points to add more
% to the curve. Press return to terminate program.
%% This fuction is different from the text book written by the editor of the book.
%% Apart from the original functions, Dr. Wang has added its own codes to the function 
%% in order to 1) move the entire graph to positive; 2)
function modifiedbezierdraw
clear all;
close all
clc
plot([0 2],[1,1],'k',[1 1],[0 2],'k');hold on %% Modified to move the entire graph to positive.
%imshow('1588.jpg');hold on
t=0:.02:1;
xlist=[]; ylist=[]; %% Used to store the coordinate list.
[x,y]=ginput(1); % get one mouse click
xlist(1)=x; ylist(1)=y; %% Starting coordinate
while(0 == 0)
[xnew,ynew] = ginput(3); % get three mouse clicks
if length(xnew) < 3
break % if return pressed, terminate
end
xlist(length(xlist)+1:length(xlist)+3)=xnew; ylist(length(ylist)+1:length(ylist)+3)=ynew; %% Store the current three coordinates
x=[x;xnew];y=[y;ynew]; % plot spline points and control pts
plot([x(1) x(2)],[y(1) y(2)],'r:',x(2),y(2),'rs');
plot([x(3) x(4)],[y(3) y(4)],'r:',x(3),y(3),'rs');
plot(x(1),y(1),'bo',x(4),y(4),'bo');
bx=3*(x(2)-x(1)); by=3*(y(2)-y(1)); % spline equations ...
cx=3*(x(3)-x(2))-bx;cy=3*(y(3)-y(2))-by;
dx=x(4)-x(1)-bx-cx;dy=y(4)-y(1)-by-cy;
xp=x(1)+t.*(bx+t.*(cx+t*dx)); % Horner's method
yp=y(1)+t.*(by+t.*(cy+t*dy));
plot(xp,yp) % plot spline curve
x=x(4);y=y(4); % promote last to first and repeat
end
hold off
%% The remaining codes are used to store the coordinates 
%% and write them in the format of .txt which can be directly used in PDF.
save('xylist.mat','xlist','ylist');
xlist=xlist*300;
ylist=ylist*300;
fid=fopen('fontmat.txt','w');
for i=0:(length(xlist)-1)/3-1
    fprintf(fid,'%d %d %d %d %d %d %d %d c\n',fix(xlist(i*3+1)), fix(ylist(i*3+1)), fix(xlist(i*3+2)), fix(ylist(i*3+2)), fix(xlist(i*3+3)), fix(ylist(i*3+3)), fix(xlist(i*3+4)), fix(ylist(i*3+4)));
end
fclose(fid);

pdf使用1.7老版本的定义:
注意stream区间,第一行m为起点,即第一行c的首两个整数。使用程序会得到一份txt文件。复制并替换带c的行数即可。末尾S需保留。

%PDF-1.7
1 0 obj
<<
/Length 2 0 R
>>
stream
151 421 m
151 421 150 411 169 406 179 406 c
179 406 195 406 261 404 396 409 c
396 409 369 378 343 365 183 323 c
183 323 206 306 328 321 373 327 c
373 327 355 285 219 264 134 241 c
134 241 180 227 349 228 408 228 c
408 228 434 214 429 109 420 95 c
420 95 401 99 400 111 398 125 c
398 125 378 178 299 465 284 493 c
284 493 284 430 282 149 279 102 c
S
endstream
endobj
2 0 obj
1000
endobj
4 0 obj
<<
/Type /Page
/Parent 5 0 R
/Contents 1 0 R
>>
endobj
5 0 obj
<<
/Kids [4 0 R]
/Count 1
/Type /Pages
/MediaBox [0 0  612 792]
>>
endobj
3 0 obj
<<
/Pages 5 0 R
/Type /Catalog
>>
endobj
xref
0 6
0000000000 65535 f 
0000000100 00000 n 
0000000200 00000 n 
0000000500 00000 n 
0000000300 00000 n 
0000000400 00000 n 
trailer
<<
/Size 6
/Root 3 0 R
>>
startxref
1000
%%EOF

查看更多关于【matlab】的文章

展开全文
相关推荐
反对 0
举报 0
评论 0
图文资讯
热门推荐
优选好物
更多热点专题
更多推荐文章
如何在Abaqus的python中调用Matlab程序
目录1. 确定版本信息2. 备份python3. 设置环境变量4. 安装程序5. 调试运行参考资料Abaqus2018操作系统Win10 64位Python版本2.7(路径C:\SIMULIA\CAE\2018\win_b64\tools\SMApy\python2.7)2. 备份python将上述的“python2.7”文件夹复制出来,避免因操作错误

0评论2023-03-16608

ROS与Matlab系列:一个简单的运动控制 基于matlab的运动控制系统
转自:http://blog.exbot.net/archives/2594Matlab拥有强大的数据处理、可视化绘图能力以及众多成熟的算法函数,非常适合算法开发;在控制系统设计中,Simulink也是普遍使用的设计和仿真工具。而ROS系统,则是一种新的标准化机器人系统软件框架。通过ROS,你

0评论2023-02-10920

matlab 遍历结构体struc的成员
MATLAB中专门用于对结构数组的操作的函数并不多,通过 help datatypes获取数据类型列表,可以看到其中的结构数据类型的有关的函数,主要如表4.3.1所示。表4.3.1 结构数组的操作函数函数名             功能描述 deal                 把输入处

0评论2023-02-09712

matlab编程如何换行 matlab怎么换行
空格+三个点+逗号

0评论2023-02-09691

C/C++中调用matlab引擎计算 matlab转c
原帖地址:http://blog.sina.com.cn/s/blog_6adcb3530101cvot.html一,在linux环境使用matlab引擎必须先进行一些必要的配置1,matlab引擎依赖/bin/csh启动,所以不管你使用何种shell,都必须安装csh。**2,matlab引擎依赖的动态库文件目录必须在系统当前的

0评论2023-02-09451

matlab几何纠正,间接法,双线性内插
超简洁,超级快,两个文件datapre.m文件代码:global X;global Y;global A;global l;global i;global I;global m;global n;global k;global dx;  A=[];l=[];i=0;m=[];n=[];dx=[]; fig=figure;subplot(1,2,1);I=imread('编程实习2-待纠正图像.bmp');imshow(I

0评论2023-02-09482

Matlab 根号的输入
二次根号:sqrt(a)或a^0.5三次根号:x^(1/3)或者x.^(1/3)根据x的数据结构类型矩阵、数组需要.^

0评论2023-02-09969

命令视频Matlab下查看摄像头设备信息
时间紧张,先记一笔,后续优化与完善。    应用如下2个命令:         info = imaqhwinfo('winvideo')    每日一道理 俄国作家契诃夫说:“有大狗,有小狗,小狗不该因为大狗的存在而心慌意乱。所有的狗都应该叫,就让他各自用上帝给他的声音

0评论2023-02-09957

How to use the HMM toolbox (Matlab)
一、离散输出的隐马尔科夫模型(DHMM,HMM with discrete outputs)最大似然参数估计EM(Baum Welch算法)The script dhmm_em_demo.m gives an example of how to learn an HMM with discrete outputs. Let there be Q=2 states and O=3 output symbols. We c

0评论2023-02-09459

permutation 随机置换检验的Matlab程序
假定a为某指标在10个样本中的值,5个一组,看以两组均值的差为例(统计量),随机置换检验程序 example: a: 230 -1350 -1580 -400 -760 970 110 -50 -190 -200v1=sum(a(1:5))/5;v2=sum(a(6:10))/5;T=abs(v1-v2);x=perms(a);      %矩阵a的全排列(随机全

0评论2023-02-09662

MATLAB学习1 之画图函数
ezplot适用条件“ezplot”命令可以用于显函数、隐函数和参数方程作图。不同函数的使用格式显函数y=f(x),ezplot函数的调用格式为ezplot(f, [xmin xmax]);              例:ezplot(\'sin(10*pi*x)/x\',[1 2]);%画出函数曲线隐函数f(x,y)=0,ezplot函数的

0评论2023-02-09591

Matlab 之 数据元素访问
Matlab的含义是矩阵实验室,其特征之一就是数据的向量化操作,借此提升软件运行效率。那么,必然会涉及数据元素的访问。Matlab主要支持下面一些形式的访问:(1)array-inde: A(i)(2)cell-index: C{i}(3)struct field: S.fieldname不同的访问方式,效

0评论2023-02-09994

更多推荐