x=1;
y=2;
theta=pi/10;
r=05;
axis equal
t = linspace(0+theta,2pi+theta,6);
xr = x+rcos(t);
yr = y+rsin(t);
xk = zeros(1,11);
yk = zeros(1,11);
xk(1) = xr(1); yk(1) = yr(1); [xk(2) yk(2)] = CrossPoint([xr(1) yr(1)],[xr(3) yr(3)],[xr(2) yr(2)],[xr(5) yr(5)]);
xk(3) = xr(2); yk(3) = yr(2); [xk(4) yk(4)] = CrossPoint([xr(2) yr(2)],[xr(4) yr(4)],[xr(1) yr(1)],[xr(3) yr(3)]);
xk(5) = xr(3); yk(5) = yr(3); [xk(6) yk(6)] = CrossPoint([xr(2) yr(2)],[xr(4) yr(4)],[xr(3) yr(3)],[xr(5) yr(5)]);
xk(7) = xr(4); yk(7) = yr(4); [xk(8) yk(8)] = CrossPoint([xr(3) yr(3)],[xr(5) yr(5)],[xr(1) yr(1)],[xr(4) yr(4)]);
xk(9) = xr(5); yk(9) = yr(5); [xk(10) yk(10)] = CrossPoint([xr(1) yr(1)],[xr(4) yr(4)],[xr(2) yr(2)],[xr(5) yr(5)]);
xk(11)=xk(1);yk(11)=yk(1);
plot(xk,yk);
%fill(xk,yk,'w')
axis equal
axis off;
需要另写一个函数,计算交叉点
function [x,y]=CrossPoint(p1,p2,p3,p4)x1 = p1(1); y1 = p1(2);
x2 = p2(1); y2 = p2(2);
x3 = p3(1); y3 = p3(2);
x4 = p4(1); y4 = p4(2);
if x1==x2
x = x1;
k2 = (y4-y3)/(x4-x3);
y = k2(x-x3)+y3;
elseif x3==x4
x = x3;
k1 = (y2-y1)/(x2-x1);
y = k1(x-x1)+y1;
else
k1 = (y2-y1)/(x2-x1);
k2 = (y4-y3)/(x4-x3);
sol = [-k1 1;-k2 1]\[y1-k1x1;y3-k2x3];
x = sol(1);y = sol(2);
end
end%圆球
syms x y z;
F=x^2+y^2+z^2-16;
nv=jacobian(F,[x y z]);
[x,y,z]=sphere;
surf(4x,4y,4z);
shading interp
%指定某点
x=-1;y=-2;z=sqrt(16-x^2-y^2);
nv=double(subs(nv));
hold on;
quiver3(x,y,z,nv(1),nv(2),nv(3),5);%法向量
t=-1:5:1;
[xx,yy]=meshgrid(t+x,t+y);
zz=-(nv(1)(xx-x)+nv(2)(yy-y))/nv(3)+z;
mesh(xx,yy,zz);%切平面clear all;
close all;
figure;hold on;
x1=[0 10 10 0 0];
y1=[0 0 0 0 0];
z1=[0 0 10 10 0];
x2=[10 10 10 10 10];
y2=[0 10 10 0 0];
z2=[0 0 10 10 0];
x3=[0 10 10 0 0];
y3=[10 10 10 10 10];
z3=[0 0 10 10 0];
x4=[0 0 0 0 0];
y4=[0 10 10 0 0];
z4=[0 0 10 10 0];
plot3(x1,y1,z1,'Color',[0 0 0]);
plot3(x2,y2,z2,'Color',[0 0 0]);
plot3(x3,y3,z3,'Color',[0 0 0]);
plot3(x4,y4,z4,'Color',[0 0 0]);
% plot3(x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,x5,y5,z5,'Color',[0 0 0]);
view(3);
x=0:01:10;
z=04(x-5)^2;
y=zeros(length(x));
hold on;
plot3(x,y,z);
y=10ones(length(x));
plot3(x,y,z);
y=0:01:10;
z=04(y-5)^2;
x=zeros(length(x));
plot3(x,y,z);
x=10ones(length(x));
plot3(x,y,z);
set(gca,'xtick',[],'xticklabel',[]);
set(gca,'ytick',[],'yticklabel',[]);
set(gca,'ztick',[],'zticklabel',[]);
由于x,y,z均和t有关,所以其实是一条三维曲线
程序:
t=-3:pi/50:3;
x=sin(3t);
y=cos(3t);
Z=2x^2+y^2;
plot3(x,y,Z)
grid on
clear all;clc;
P=05;
T=00005;
N=000002:000002:00002;
k=sqrt((2PT)/N);
z=erfc(k)/2;
plot(N,z);
y=[1,3,0,20,20,4,18];
x=0:(length(y)-1);
x1=-05:02:55;
y1=interp1(x,y,x1,'spline');(三次样条差值)
y2=interp1(x,y,x1,'cubic');(三次多样式差值,不是三次差值)
plot(x1,y1,'bd');title('三次样条差值插值函数图象');
plot(x1,y2,'rp');title('三次多样式差值插值函数图象');
(样本点已被标记出来的)
请楼下的不要抄袭,而且,你也抄错了,三次多样式差值不要用y1表示,和三次样条差值重复了
以上就是关于用matlab进行M文件 *** 作与画图,绘图的,我要程序过程,都是编程题.全部的内容,包括:用matlab进行M文件 *** 作与画图,绘图的,我要程序过程,都是编程题.、matlab 绘制曲面图程序、求高手帮写一个MATLAB中绘图的程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)