1. Trang chủ
  2. » Tất cả

Matlab giai tich

69 1 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Giải Tích
Trường học Unknown University
Chuyên ngành Mathematics
Thể loại Bài Tập
Năm xuất bản 2023
Thành phố Unknown City
Định dạng
Số trang 69
Dung lượng 130,15 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

GIẢI TÍCH NHÓM 1 function n1b1 % chuong trinh ve parabol elliptic a=input(''''nhap so a= ''''); b=input(''''nhap so b= ''''); [x,y]=meshgrid( 10 05 10); z=x ^2/a+y ^2/b; % lenh for o duoi de cat got do thi cho de[.]

Trang 1

u=input('nhap ham u(x,y)= ');

disp(['dao ham rieng theo x cap 10 tai (1,2) la: ' num2str(subs(diff(u,10,x) ,[x y],[1 2]))])

%lenh diff la dao ham

% lenh subs la thay x va y bang so x0 va y0

end

function n1b3

clc

syms x y real

f=input('nhap ham f(x,y)= ');

[a b]=solve([char(diff(f,'x')) '=0'],[char(diff(f,'y')) '=0']); % giai dao ham cap 1

sA=eval(A);sB=eval(B);sC=eval(C); %tim A,B,C

delta=(sA*sC-sB^2); %tinh delta

elseif sA < 0 % A > 0 la cuc dai

cd=[cd;a(i) b(i)]; zcd=[zcd;eval(f)];

i=1+i;

else

a(i)=[];b(i)=[];

n=n-1;

Trang 2

f=char(f);f=strrep(f,'^','.^');f=strrep(f,'*','.*');f=eval(f);

else % khong co cuc tri

disp('f khong co cuc tri chat, con co cuc tri ko chat hay khong thi chiu :))' )

set(surf(x,y,z),'facecolor','r','edgecolor','non')

text(cd(i,1),cd(i,2),zcd(i)+.1,['cuc dai (' num2str(cd(i,1)) ',' num2str(cd(i,2)) ','

set(surf(x,y,z),'facecolor','r','edgecolor','non')

text(ct(i,1),ct(i,2),zct(i)-.1,['cuc tieu (' num2str(ct(i,1)) ',' num2str(ct(i,2)) ','

Trang 3

end

end

end

function n1b5

[x,y]=meshgrid(-sqrt(3):.05:sqrt(3)); % tao luoi

z=sqrt(4-x.^2-y.^2); % mat tren

z2=-sqrt(4-x.^2-y.^2)+2; % mat duoi

for i=1:length(x) % vong lap loai bo cac diem nam ngoai mien giao nhau

set(surf(x,y,z2),'facecolor','b','edgecolor','non','facealpha',.3) % ve mat duoi

pcolor(x,y,z2) % ve hinh chieu

hold off

rotate3d on

syms x y phi real

z=sqrt(4-x^2-y^2); z2=-sqrt(4-x^2-y^2)+2;

x=2*r*cos(phi);y=2*r*sin(phi); % dat x,y theo toa do truc

z=eval(z);z2=eval(z2); % cap nhat bien moi cho x va y

V=int(int(4*r*(z-z2),'r',0,sqrt(3/4)),'phi',0,2*pi); %tinh tich phan kep

g=eval(f); %thay x vao f

g=g*sqrt(1+diff(x,'y')^2); % tinh tich phan duong loai 1

l=int(g,'y',-1,1); % tinh tich phan

Trang 4

n=[diff(f,'x') diff(f,'y') diff(f,'z')];

n=n/sqrt(diff(f,'x')^2 + diff(f,'y')^2 + diff(f,'z')^2); % tinh vector don vi cua vector phap

%phuong phap tinh la phuong phap stokes

p=(diff(R,'y')-diff(Q,'z'))*n(1,1);

q=(diff(P,'z')-diff(R,'x'))*n(1,2);

r=(diff(Q,'x')-diff(P,'y'))*n(1,3);

z=y^2;

f=(eval(p)+eval(q)+eval(r))*sqrt(1+diff(z,'x')^2+diff(z,'y')^2);

% da chuyen ve tich phan mat loai 1

syms r phi real

x=r*cos(phi);y=r*sin(phi); % chuyen sang phuong phap truc toa do

f=eval(f);

S=int(int(f*r,'r',0,1),'phi',0,2*pi); %tinh tich phan

S=double(S);

disp(['Tich phan can tinh la: I= ' num2str(S)])

% ve vector phap tai M0

disp('nhap diem M0 thuoc mat z=y^2 va x^2+y^2 <= 1 ')

disp('vidu M(0,1,1), thi ta nhap: 0,1,1')

m=input('M0= ','s');

m=str2num(m);

x=m(1,1);y=m(1,2);z=m(1,3);

n=eval(n);% the toa do diem vao vector

title(['mat z=y^2 nam trong hinh tru x^2+y^2=1 ' 'Va phap vector tai diem M0(' num2str(x)

',' num2str(y) ',' num2str(z) ')']) % tao tieu de

%bat dau ve vector phap

% co nhieu cach ve ban co the dung ham tu viet de ve

% nhung o day toi se ve bang ham thu viet cua matlab rat don gian

%trong do: 0,0,0 la toa do tam

% a,b,c lan luoc la ban kinh truc Ox, Oy, Oz

Trang 5

function n2b2

syms x y z real

f=input('nhap ham z(x,y)= ');

disp('nhap lan luoc toa do M0 thuoc z(x,y)')

x0=input('x0= ');y0=input('y0= ');z0=input('z0= ');

f1=f-z; %chuyen thanh f(x,y,z)=0

n=[ diff(f1,'x') diff(f1,'y') diff(f1,'z')]; %tinh dao ham

n1=subs(n,[x y z],[x0 y0 z0]); n1=double(n1); %tim vector gradian

f1=n1(1,1)*(x-x0)+n1(1,2)*(y-y0)+n1(1,3)*(z-z0); %mat tiep tuyen

disp(['phuonh trinh mat tiep tuyen la: ' char(f1) ' = 0' ])

disp('phuong trinh phap tuyen la: ')

% ve duong thang phap tuyen

[x y f]=loai(x,y,f); %loai bo cac diem bat dinh

set(surf(x,y,f),'facecolor','b','edgecolor','non','facealpha',.3)

%ve mat tiep tuyen

Trang 6

f=input('nhap ham f(x,y)= ');

disp('nhap a b cua ellip x^2/a+y^2/b=1')

Lxx=diff(Lx,'x');Lyy=diff(Ly,'y');Lxy=diff(Lx,'y'); %dao ham cap 2

phix=diff(phi,'x');phiy=diff(phi,'y'); %dao ham dieu kien

for i=1:length(m) %xet cuc dai, cuc tieu

if m(i)==inf || n(i)==inf || l(i)==inf

end

hold off

rotate3d on

end

%loai cac diem bat dinh

function [x y f]=khu(x,y,f) % chuong trinh loai bo cac diem khong ton tai cua ham f

Trang 7

function n2b4

syms x y real

warning off

y1=input('nhap ham y1(x)= ');

y2=input('nhap ham y2(x)= ');

f=input('nhap ham tinh tich phan f(x,y)= ');

if double(subs((y1-y2),'x',(n(1)+n(2))/2)) > 0 % neu y1 nam tren y2

I=int(int(f,'y',y2,y1),'x',n(1),n(2));

else % neu y2 nam tren y1

I=int(int(f,'y',y1,y2),'x',n(1),n(2));

Trang 8

% ve duong giao tuyen

n=[diff(f,'x') diff(f,'y') diff(f,'z')];

n=n/sqrt(diff(f,'x')^2 + diff(f,'y')^2 + diff(f,'z')^2); % tinh vector don vi cua vector phap

%phuong phap tinh la phuong phap stokes

p=(diff(R,'y')-diff(Q,'z'))*n(1,1);

q=(diff(P,'z')-diff(R,'x'))*n(1,2);

r=(diff(Q,'x')-diff(P,'y'))*n(1,3);

z=2-2*x;

% chuyen ve tich phan mat loai 1

f=(eval(p)+eval(q)+eval(r))*sqrt(1+diff(z,'x')^2+diff(z,'y')^2);

%tinh tich phan

syms r phi real

x=r*cos(phi);y=r*sin(phi); % chuyen sang phuong phap truc toa do

f=eval(f);

S=int(int(f*r,'r',0,sqrt(3)),'phi',0,2*pi); %tinh tich phan

S=double(S);

disp(['Tich phan can tinh la: I= ' num2str(S)])

% ve vector phap tai M0

disp('nhap diem M0 thuoc mat 2*x+z=2 va z >= x^2+y^2 ')

disp('vidu M(0,-1,2), thi ta nhap: 0,-1,2')

Trang 9

m=input('M0= ','s');

m=str2num(m);

x=m(1,1);y=m(1,2);z=m(1,3);

n=eval(n);% the toa do diem vao vector

title(['mat z=y^2 nam trong hinh tru x^2+y^2=1 ' 'Va phap vector tai diem M0(' num2str(x)

',' num2str(y) ',' num2str(z) ')']) % tao tieu de

%bat dau ve vector phap

f=input('nhap ham f(u)= ');

u=input('nhap ham u(x,y)= ');

disp('phap lan luoc cac toa do cua M0:')

x0=input('x0= ');

y0=input('y0= ');

f=eval(f); %thay u(x,y) vao f(u)

c=subs(f,[x y],[x0 y0]); %tinh f tai M0

Trang 10

text(x0,y0,c+.2,['M0 (' num2str(x0) ',' num2str(y0) ',' num2str(a) ')'])

syms x y lamda real

f=input('nhap ham f(x,y)= ');

disp('nhap parabol y(x) vd: y=6+4*x^2 ')

[l m n]=solve(Lx,Ly,phi-y,'x','y','lamda');

%giai he dao ham cap 1 voi: l <=> lamda , m <=> x , n <=> y

m=double(m); m(abs(imag(m))>0.0000000001)=inf;m=m-imag(m)*1i; %loai so phuc

n=double(n); n(abs(imag(n))>0.0000000001)=inf;n=n-imag(n)*1i;

l=double(l); l(abs(imag(l))>0.0000000001)=inf;l=l-imag(l)*1i;

Lxx=diff(Lx,'x');Lyy=diff(Ly,'y');Lxy=diff(Lx,'y'); %dao ham cap 2

phix=diff(phi-y,'x');phiy=diff(phi-y,'y'); %dao ham dieu kien

k=0;

for i=1:length(m) %xet cuc dai, cuc tieu

if m(i)==inf || n(i)==inf || l(i)==inf

Trang 11

set(surf(x,y,z),'facecolor','b','edgecolor','non','facealpha',.2)

%loai cac diem bat dinh

function [x y f]=khu(x,y,f) % chuong trinh loai bo cac diem khong ton tai cua ham f

x1=input('nhap ham x1(y)= ');

x2=input('nhap ham x2(y)= ');

f=input('nhap ham tinh tich phan f(x,y)= ');

Trang 12

%ve giao tuyen

Trang 13

n=[diff(f,'x') diff(f,'y') diff(f,'z')];

g=diff(P,'x')+diff(Q,'y')+diff(R,'z');

x=p*cos(phi)*sin(t);

y=p*sin(t)*sin(phi);

z=p*cos(t);

g=eval(g);

V=int(int(int(g*p^2*sin(t),'p',0,2),'t',0,pi/2),'phi',0,2*pi);

% ta tru cho tich phan mat duoi mat duoi huong xuong oz => V=V+S

n=eval(n);% the toa do diem vao vector

%bat dau ve vector phap

disp('ban mun ve Hyperboloid 1 tang hay 2 tang')

disp('neu mun ve 1 tang thi nhap: 1')

d=input('1 hay 2: ','s');d=str2double(d);

if d==1

Trang 14

d=-1;

disp('nhap cac so a b c thuoc x^2/a^2+y^2/b^2-z^2/c^2=1')

disp('nen nhap cac so nho hon 5')

elseif d==2

d=1;

disp('nhap cac so a b c thuoc x^2/a^2+y^2/b^2-z^2/c^2=-1')

disp('nen nhap cac so nho hon 5')

syms x y lamda real

f=input('nhap ham f(x,y)= ');f=sym(f);

disp(' nhap toa do I(x0,y0) va R :')

x0=input('x0= ');

y0=input('y0= ');

r=input('R= ');

%tim cuc tri trong mien D

[p q]=solve(diff(f,'x'),diff(f,'y'));

Trang 15

A(i,1)=subs(f,[x y],[p(i) q(i)]);

if a>subs(f,[x y],[x0+0.12 y0+0.12])

disp(['GTLN f(' num2str(A(1,2)) ',' num2str(A(1,3)) ')= ' num2str(A(1,1))])

Trang 16

f=input('nhap f(x,y)= ');

y1=input('nhap y1= ');

y2=input('nhap y2= ');

disp('nhap khoang [a,b]')

a=input('a= ');b=input('b= ');

disp('nhap toa do 3 dinh A,B,C vidu: toa do la A(1,2) ta nhap: 1,2')

A=input('toa do A: ','s');A=str2num(A); %chuyen tu kieu string sang kieu so

B=input('toa do B: ','s');B=str2num(B);

C=input('toa do C: ','s');C=str2num(C);

u=diff(g,'y')-diff(f,'x');

dinh=[A;B;C];

a=unique(dinh,'rows'); %sap xep cac dinh cua tam giac, theo chieu tang dan x

S=0;

Trang 17

if subs(y1-y2,'x',(a(2,1)-a(1,1))/2)>0 % xem y1 hay y2 nam tren

S=S+int(int(u,'y',y2,y1),'x',a(1,1),a(2,1)); %tich phan kep

Trang 18

title(['x^2/' num2str(a) '^2 + y^2/' num2str(b) '^2 = 1'])

u=input('u(x,y)= ');u=sym(u);

v=input('v(x,y)= ');v=sym(v);

f=eval(f); %the u v vao f

fx=diff(f,'x'); %dao ham theo x

fy=diff(f,'y'); %dao ham theo x

disp('nhap toa do M0(x0,y0)')

x0=input('x0= ');x=x0;

y0=input('y0= ');y=y0;

z0=eval(f); %the x0 y0 vao f ta dc z0

fx1=eval(fx); %the x0 y0 vao f'x

fy1=eval(fy); %the x0 y0 vao f'y

disp(['f`x(' num2str(x) ',' num2str(y) ')= ' num2str(fx1)])

disp(['f`y(' num2str(x) ',' num2str(y) ')= ' num2str(fy1)])

Trang 19

syms x y real

f=input('nhap ham f(x,y)= ');

[a b]=solve([char(diff(f,'x')) '+0*x=0'],[char(diff(f,'y')) '+0*y=0'],'x','y'); % giai dao ham cap 1

[a b]=voso(a,b); % loai vo so nghiem

if a>subs(f,[x y],[x0+0.12 y0+0.12])

disp(['GTLN f(' num2str(c(1,2)) ',' num2str(c(1,3)) ')= ' num2str(c(1,1))])

Trang 20

x=[c(i,2)-d/10 c(i,2) c(i,2)+d/10];

y=[c(i,3)-d/10 c(i,3) c(i,3)+d/10];

x=[c(i,2)-d/10 c(i,2) c(i,2)+d/10];

y=[c(i,3)-d/10 c(i,3) c(i,3)+d/10];

Trang 21

if double(subs((x1-x2),'y',(a+b)/2)) > 0 % neu x1 nam ben phai x2

I=int(int(f,'x',x2,x1),'y',a,b);

I=double(I);

disp(['tich phan can tinh I= ' num2str(I)])

ve(x1,x2,a,b)

else % neu x2 nam ben phai x1

I=int(int(f,'x',x1,x2),'y',a,b);

Trang 22

disp(['I= ' num2str(I)])

disp('ta dat: ')

disp('nhap toa do 3 dinh A,B,C vidu: toa do la A(1,2) ta nhap: 1,2')

A=input('toa do A: ','s');A=str2num(A); %chuyen tu kieu string sang kieu so

B=input('toa do B: ','s');B=str2num(B);

C=input('toa do C: ','s');C=str2num(C);

u=diff(g,'x')-diff(f,'y');

u=-u; % theo chieu kim dong ho

dinh=[A;B;C];

Trang 23

a=unique(dinh,'rows'); %sap xep cac dinh cua tam giac, theo chieu tang dan x

if subs(y1-y2,'x',(a(2,1)-a(1,1))/2)>0 % xem y1 hay y2 nam tren

S=S+int(int(u,'y',y2,y1),'x',a(1,1),a(2,1)); %tich phan kep

text(a(1,1),a(1,2),['(' num2str(a(1,1)) ',' num2str(a(1,2)) ')'])

text(a(2,1),a(2,2),['(' num2str(a(2,1)) ',' num2str(a(2,2)) ')'])

text(a(3,1),a(3,2),['(' num2str(a(3,1)) ',' num2str(a(3,2)) ')'])

Trang 24

disp('nhap toa do M0(x0,y0,y0) thuoc mat cau x^2+y^2+z^2=4')

x0=input('x0= ');

y0=input('y0= ');

z0=input('z0= ');

if abs(x0^2+y0^2+z0^2-4)>0.00001 %kiem tra M0

disp('nhap sai M0')

n=[diff(f,'x') diff(f,'y') diff(f,'z')];

n=n/sqrt(diff(f,'x')^2+diff(f,'y')^2+diff(f,'z')^2);

%code ve mat bac 2

disp('nhap lan luoc a b c d e f g cua mat bac 2theo cong thuc sau:')

disp('a*x^2 + b*y^2/b^2 + c*z^2 + d*xy + e*xz + f*yz + g*x + h*y + i*z = j')a=input('a= ');

Trang 25

surf(x,y,z1,'FaceColor','r','EdgeColor','none');

Trang 26

mesh(x,y,z1,'EdgeColor','r','FaceAlpha',0.1);

%%%%%%%%%%%% Phan mat y=0 %%%%%%%%%%%%%%%%%%%

surf(x,y,z,'FaceColor','r','EdgeColor','none','FaceAlpha',0.5);

%%%%%%%%%%%% Phan mat x= y^2 %%%%%%%%%%%%%%%%%

surf(x,y,z,'EdgeColor','none','FaceColor','r','FaceAlpha',0.2);

%%%%%%%%%%%% Phan mat x+y+z=3 va z=0 %%%%%%%%%%

mesh(x,y,z,'EdgeColor','r','FaceAlpha',0.3);

surf(x,y,z1,'EdgeColor','none','FaceColor','g');

%%%%%%%%%% Phan mat 3x+2y=6%%%%%%%%%%%%%

Trang 27

mesh(x,y,z,'EdgeColor','b','FaceAlpha',0.3);

%%%%%%%%%% Phan mat 3x+y=3%%%%%%%%%%%%%

surf(x,y,z,'EdgeColor','none','FaceColor','y');

%%%%%%%%%% Phan mat y=0 %%%%%%%%%%%%%

surfc(x,y,z,'FaceColor','b','EdgeColor','r','FaceAlpha',0.7);

%%%%%%%%%%%%%%%%% Nua cau tren %%%%%%%%%%%%%%%%%%

Trang 28

%%%%%%%%%%%%%%% Mat paraboloid va mat z=0%%%%%%%%%%%%

Trang 31

function [h,yy,zz] = arrow(varargin)

% ARROW Draw a line with an arrowhead

%

% ARROW(Start,Stop) draws a line with an arrow from Start to Stop (points

% should be vectors of length 2 or 3, or matrices with 2 or 3

% columns), and returns the graphics handle of the arrow(s)

% the full normal argument list, where all but the Start and Stop

% points are optional If you need to specify a later argument (e.g.,

% Page) but want default values of earlier ones (e.g., TipAngle),

% pass an empty matrix for the earlier ones (e.g., TipAngle=[])

%

% ARROW('Property1',PropVal1,'Property2',PropVal2, ) creates arrows with the

% given properties, using default values for any unspecified or given as

% 'default' or NaN Some properties used for line and patch objects are

% used in a modified fashion, others are passed directly to LINE, PATCH,

% or SET For a detailed properties explanation, call ARROW PROPERTIES

%

% Start The starting points B

% Stop The end points /|\ ^

% Length Length of the arrowhead in pixels /|||\ |

% BaseAngle Base angle in degrees (ADE) //|||\\ L|

% TipAngle Tip angle in degrees (ABC) ///|||\\\ e|

% Width Width of the base in pixels ////|||\\\\ n|

% Page Use hardcopy proportions /////|D|\\\\\ g|

% CrossDir Vector || to arrowhead plane //// ||| \\\\ t|

% NormalDir Vector out of arrowhead plane /// ||| \\\ h|

% Ends Which end has an arrowhead //< ->|| \\ |

% ObjectHandles Vector of handles to update / base ||| \ V

% E angle||< ->C

% ARROW(H,'Prop1',PropVal1, ), where H is a |||tipangle

% vector of handles to previously-created arrows |||

% and/or line objects, will update the previously- |||

% created arrows according to the current view >|A|< width

% and any specified properties, and will convert

% two-point line objects to corresponding arrows ARROW(H) will update

% the arrows if the current view has changed Root, figure, or axes

% handles included in H are replaced by all descendant Arrow objects

%

% A property list can follow any specified normal argument list, e.g.,

% ARROW([1 2 3],[0 0 0],36,'BaseAngle',60) creates an arrow from (1,2,3) to

% the origin, with an arrowhead of length 36 pixels and 60-degree base angle

%

% The basic arguments or properties can generally be vectorized to create

% multiple arrows with the same call This is done by passing a property

% with one row per arrow, or, if all arrows are to have the same property

% value, just one row may be specified

%

% You may want to execute AXIS(AXIS) before calling ARROW so it doesn't change

Trang 32

% the axes on you; ARROW determines the sizes of arrow components BEFORE the

% arrow is plotted, so if ARROW changes axis limits, arrows may be malformed

%

% This version of ARROW uses features of MATLAB 6.x and is incompatible with

% earlier MATLAB versions (ARROW for MATLAB 4.2c is available separately);

% some problems with perspective plots still exist

% Copyright (c)1995-2009, Dr Erik A Johnson <JohnsonE@usc.edu>, 5/20/2009

% http://www.usc.edu/civil_eng/johnsone/

% Revision history:

% 5/20/09 EAJ Fix view direction in (3D) demo

% 6/26/08 EAJ Replace eval('trycmd','catchcmd') with try, trycmd; catch,

% catchcmd; end; break's MATLAB 5 compatibility

% 8/26/03 EAJ Eliminate OpenGL attempted fix since it didn't fix anyway

% 11/15/02 EAJ Accomodate how MATLAB 6.5 handles NaN and logicals

% 7/28/02 EAJ Tried (but failed) work-around for MATLAB 6.x / OpenGL bug

% if zero 'Width' or not double-ended

% 11/10/99 EAJ Add logical() to eliminate zero index problem in MATLAB 5.3

% 11/10/99 EAJ Corrected warning if axis limits changed on multiple axes

% 11/10/99 EAJ Update e-mail address

% 2/10/99 EAJ Some documentation updating

% 2/24/98 EAJ Fixed bug if Start~=Stop but both colinear with viewpoint

% 8/14/97 EAJ Added workaround for MATLAB 5.1 scalar logical transpose bug

% 7/21/97 EAJ Fixed a few misc bugs

% 7/14/97 EAJ Make arrow([],'Prop', ) do nothing (no old handles)

% 6/23/97 EAJ MATLAB 5 compatible version, release

% 5/27/97 EAJ Added Line Arrows back in Corrected a few bugs

% 5/26/97 EAJ Changed missing Start/Stop to mouse-selected arrows

% 5/19/97 EAJ MATLAB 5 compatible version, beta

% 4/13/97 EAJ MATLAB 5 compatible version, alpha

% 1/31/97 EAJ Fixed bug with multiple arrows and unspecified Z coords

% 12/05/96 EAJ Fixed one more bug with log plots and NormalDir specified

% 10/24/96 EAJ Fixed bug with log plots and NormalDir specified

% 11/13/95 EAJ Corrected handling for 'reverse' axis directions

% 10/06/95 EAJ Corrected occasional conflict with SUBPLOT

% 4/24/95 EAJ A major rewrite

% Fall 94 EAJ Original code

% Things to be done:

% - in the arrow_clicks section, prompt by printing to the screen so that

% the user knows what's going on; also make sure the figure is brought

% to the front

% - segment parsing, computing, and plotting into separate subfunctions

% - change computing from Xform to Camera paradigms

% + this will help especially with 3-D perspective plots

% + if the WarpToFill section works right, remove warning code

% + when perpsective works properly, remove perspective warning code

% - add cell property values and struct property name/values (like get/set)

% - get rid of NaN as the "default" data label

% + perhaps change userdata to a struct and don't include (or leave

% empty) the values specified as default; or use a cell containing

% an empty matrix for a default value

% - add functionality of GET to retrieve current values of ARROW properties

% Many thanks to Keith Rogers <kerog@ai.mit.com> for his many excellent

% suggestions and beta testing Check out his shareware package MATDRAW

% (at ftp://ftp.mathworks.com/pub/contrib/v5/graphics/matdraw/) he has

% permission to distribute ARROW with MATDRAW

% Permission is granted to distribute ARROW with the toolboxes for the book

% "Solving Solid Mechanics Problems with MATLAB 5", by F Golnaraghi et al

% (Prentice Hall, 1999)

Trang 33

% Permission is granted to Dr Josef Bigun to distribute ARROW with his

% software to reproduce the figures in his image analysis text

% global variable initialization

global ARROW_PERSP_WARN ARROW_STRETCH_WARN ARROW_AXLIMITS

if isempty(ARROW_PERSP_WARN ), ARROW_PERSP_WARN =1; end;

if isempty(ARROW_STRETCH_WARN), ARROW_STRETCH_WARN=1; end;

if strncmp(arg1,'prop',4), arrow_props;

elseif strncmp(arg1,'demo',4)

if (nargout>3), error([upper(mfilename) ' produces at most 3 output arguments.']); end;

% find first property number

error([upper(mfilename) ' requires that the property '''

varargin{nargin} ''' be paired with a property value.']);

end;

end;

% default output

Trang 34

defstart = [NaN NaN NaN];

defstop = [NaN NaN NaN];

% parse property pairs

if strncmp(prop,'start' ,5), start = val;

elseif strncmp(prop,'stop' ,4), stop = val;

elseif strncmp(prop,'len' ,3), len = val(:);

elseif strncmp(prop,'base' ,4), baseangle = val(:);

elseif strncmp(prop,'tip' ,3), tipangle = val(:);

elseif strncmp(prop,'wid' ,3), wid = val(:);

elseif strncmp(prop,'page' ,4), page = val;

elseif strncmp(prop,'cross' ,5), crossdir = val;

elseif strncmp(prop,'norm' ,4), if (isstr(val)), crossdir=val; else, crossdir=val*sqrt(-1); end;

elseif strncmp(prop,'end' ,3), ends = val;

elseif strncmp(prop,'object',6), oldh = val(:);

elseif strncmp(prop,'handle',6), oldh = val(:);

Ngày đăng: 04/04/2023, 00:01

TỪ KHÓA LIÊN QUAN

w