How to plot 3D grid (cube) in Matlab

前端 未结 6 1212
太阳男子
太阳男子 2020-12-05 08:13

Hi I would like to plot transparent cube-shaped grid with lines in it. Something like this: \"enter

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-05 08:35

    A more vectorized version of Stephen's answer might be the following:

    i = 0:0.2:2;
    [X Y] = meshgrid(i,i);                         
    x = [X(:) X(:)]';                                
    y = [Y(:) Y(:)]';
    z = [repmat(i(1),1,length(x)); repmat(i(end),1,length(x))];
    col = 'b';
    hold on;
    plot3(x,y,z,col);                                         
    plot3(y,z,x,col);
    plot3(z,x,y,col);
    

    Unfortunately, MATLAB does not currently support transparent lines (to my knowledge). If you really need them to be transparent I'd suggest using 'patch'.

提交回复
热议问题