开发者

Plot from Mathematica to Matlab

I have this problem in Mathematica :

  L=16;
  f[x_]:=-x;
  mlat = Table[2 RandomInteger[] -开发者_如何学Go 1, {L}, {L}];
  ArrayPlot[mlat, ColorFunction -> (If[# == 1, White, Black] &), Mesh -> All]

and I did this in Matlab:

 L=16;
 f=@ (x) -x;
 mlat=2*randint(L,L)-1;
    if mlat(:,:)==1   
      plot(mlat,'ws')
      hold on
    else
        plot(mlat,'ks')
        hold off
        grid on
    end

but I can't get the graph.


First, you want to create an array with only ones and zeros, which you do using randi

L = 16;
mlat = 2*(randi([0,1],L,L)-0.5);

Then, you can display this as an image (I like to open an new figure for every plot)

figure
imshow(mlat,[]) %# [] scales to min...max

To make the image bigger, set axes size to 90% of the figure window

set(gca,'Units','normalized','Position',[0.05 0.05 0.9 0.9],'visible','on')

Plot from Mathematica to Matlab

Note that the axes label correspond to the index of matrix elements, so (1,1) is top left.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜