matlab学习(2)

% 改用不同的步长,观察曲线是否相同
% x = [-pi : 0.001 : pi];
% x = [-pi:0.05:-1.8, -1.801:.001:-1.2, …
% -1.2:0.05:1.2, 1.201:0.001:1.8, …
% 1.81:0,05:pi
% ];
% y = sin(tan(x))-tan(sin(x));
% plot(x,y);

% 分段函数
% x = [-2:0.02:2];
% y = 1.1sign(x).(abs(x)>1.1) + …
% x.*(abs(x) <= 1.1);
% plot(x,y);

% 多轴曲线:
% x = 0:0.01:2pi;
% y1 = sin(x); y2 = 0.01
cos(x);
% yyaxis left
% plot(x, y1, ‘–’);
%
% yyaxis right
% plot(x, y2, ‘–’);

% 特殊的二维图形
% theta = 0:0.01:6pi;
% rho = 5
sin(4theta/3);
% polarplot(theta,rho); % 画极坐标图像
% rho = 5
sin(theta/3);
% polarplot(theta, rho);

% t = 0:.2:2*pi; y = sin(t);
% subplot(2,2,1), stairs(t,y); % 阶梯图
% subplot(2,2,2), stem(t,y); % 火柴图
% subplot(2,2,3), bar(t,y); % 直方图
% subplot(2,2,4), semilogx(t,y); % 横轴取对数

% 隐函数绘制 ezplot()
% h = ezplot(‘x^2 * sin(x+y^2) + y^2 * exp(x+y) + 5*cos(x^2+y)’,[-10,10]); % 扩大范围
% set(h, ‘Color’,‘b’);

% 三维图形表示
% t = 0:.01:2*pi;
% x = t.^3.sin(3t).*exp(-t);
% y = t.^3.cos(3t).*exp(-t);
% z = t.^2;
% figure(1)
% hold on % 保持当前坐标系
% plot3(x, y, z);
% grid on
% stem3(x,y,z); hold on
% plot3(x,y,z); hold off
%
% figure(2)
% comet3(x,y,z); % 三维动态图

% 曲面图的绘制
% [x,y]= meshgrid(-3:0.1:3, -2:0.1:2);
% z = (x.2-2*x).*exp(-x.2-y.^2-x.*y);
% figure(1)
% mesh(x,y,z);
% hold off;
% figure(2)
% surf(x,y,z);
% hold off;

% [x,y] = meshgrid(-2:.1:2);
% z = 1./(sqrt((1-x).2+y.2)) + 1./(sqrt((1+x).^2 + y.^2));
% figure(1)
% surf(x,y,z);
% hold off;
% figure(2)
% surf(x,y,z);
% shading flat % 小网格边界不明显
% hold off;

% 分段函数绘图
% [x1, x2] = meshgrid(-1.5:.1:1.5, -2:.1:2);
% p = 0.5457exp(-0.75x2.^2 - 3.75x1.^2-1.5x1).(x1+x2>1) + …
% 0.7575
exp(-x2.^2 - 6x1.^2).((x1+x2>-1)&(x1+x2<=1)) + …
% 0.5457exp(-0.75x2.^2 - 3.75x1.^2+1.5x1).*(x1+x2<=-1);
% surf(x1, x2, p);
% shading flat % 小网格边界不明显
% xlim([-1.5 1.5]);

% 参数方程
% syms u v;
% x = cos(u) + vcos(u)cos(u/2);
% y = sin(u) + v
sin(u)cos(u/2);
% z = v
sin(u/2);
% ezsurf(x, y, z, [0,2
pi, -0.5, 0.5]);

% 球面绘制
% 返回半径等于 1
% 且包含 n×n 个面的球面的 x、y 和 z 坐标。
% % 该函数以三个 (n+1)×(n+1) 矩阵形式返回 x、y 和 z 坐标。
% [x, y, z] = sphere(50);
% surf(x, y, z);
% hold on;
% shading flat
%
% x1 = 0.3x+0.9;
% y1 = 0.3
y-0.8;
% z1 = 0.3*z + 0.6;
% surf(x1, y1, z1);
% shading flat

% 柱面绘制
% z0 = -1:.1:3;
% r = exp(-z0.^2/2).sin(z0);
% [x, y, z] = cylinder®; % 某曲线r绕着z轴旋转一圈得出柱面
% % z = -1+4
z;
% figure(1)
% surf(x, y, z);
%
% figure(2)
% z = -1+4*z;
% surf(x, y, z);

% 三视图的设置
% [x, y] = meshgrid(-3:0.1:3, -2:0.1:2);
% z = (x.^2 - 2*x).*exp(-x.2-y.2-x.*y);
% subplot(224), surf(x, y, z);
% subplot(221), surf(x, y, z); view(0, 90); % 俯视图
% subplot(222), surf(x, y, z); view(90,0); % 侧视图
% subplot(223), surf(x, y, z); view(0,0); % 正视图

% 旋转的动画演示
% figure;
% h = surf(x, y, z);
% r_ax = [1 1 1]; % 旋转轴为x轴
% axis tight
% for i = 0:360
% rotate(h, r_ax, 1); % 句柄h绕着轴r_ax,旋转1度
% pause(0.01);
% end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值