clc
clear all
close all
% matlab自带的mesh画图
N = 50;
xline = linspace(0,1,N);
yline = linspace(0,1,N);
[xmesh, ymesh] = meshgrid(xline, yline);
z = sin(xmesh).*sin(ymesh);
figure('name', 'fig1')
mesh(xmesh, ymesh, z);
hold on
% 将mesh数据变成一维的,然后计算画图
x = xmesh';
x = x(:)';
y = ymesh';
y = y(:)';
f = sin(x).*sin(y);
fm = zeros(N,N);
for i=1:N
for j=1:N
k = (i-1)*N+j;
fm(i,j)=f(k);
end
end
figure('name', 'fig2')
mesh(xline,yline, fm)
hold on
matlab下自编mesh画图程序
最新推荐文章于 2024-05-29 08:30:00 发布