matlab代码

1. 旋转变换

matlab代码_第1张图片

    clear;clc;clf;
    [x,y] = meshgrid(-3:1:3);
    z = x .* 0;
    mesh(x,y,z,'edgecolor','b');
    hold on;
    [r,c] = size(x);
    x_1 = randn(r,c);
    y_1 = randn(r,c);
    for i  = 1:r
        for j = 1:c
            temp = [cos(pi/4) sin(pi/4); -sin(pi/4) cos(pi/4)]*[x(i,j);y(i,j)];
            x_1(i,j) = temp(1,1);
            y_1(i,j) = temp(2,1);
        end
    end
    z_1 = x_1 .* 0;
    mesh(x_1,y_1,z_1,'edgecolor','r');
    alpha(.3);
    axis([-6,6,-6,6]);
    hold off;

2. 非线性变换

matlab代码_第2张图片

clear;clc;clf;
    [x,y] = meshgrid(-3:1:3);
    z = x .* 0;
    mesh(x,y,z,'edgecolor','b');
    hold on;
    [r,c] = size(x);
    x_1 = randn(r,c);
    y_1 = randn(r,c);
    for i = 1:r
        for j = 1:c
            x_1(i,j) = x(i,j) * 3;
            y_1(i,j) = y(i,j) .^ 3;
        end
    end
    z_1 = x_1 .* 0;
    mesh(x_1,y_1,z_1,'edgecolor','r');
    alpha(.3);
    axis([-30,30,-30,30]);
    hold off;

 

你可能感兴趣的:(MATLAB,线性代数)