【问题标题】:Plot from Mathematica to Matlab从 Mathematica 到 Matlab 的绘图
【发布时间】:2012-01-04 05:39:05
【问题描述】:

我在 Mathematica 中遇到了这个问题:

  L=16;
  f[x_]:=-x;
  mlat = Table[2 RandomInteger[] - 1, {L}, {L}];
  ArrayPlot[mlat, ColorFunction -> (If[# == 1, White, Black] &), Mesh -> All]

我在 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

但我无法得到图表。

【问题讨论】:

  • 我不知道 Mathematica,你的图表应该是什么样子的?
  • ising 模型,应该有正方形,白色和黑色。
  • @Ghaul:查看Mathematica help中的示例

标签: matlab wolfram-mathematica plot


【解决方案1】:

首先,您想创建一个只有 1 和 0 的数组,您可以使用 randi

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

然后,您可以将其显示为图像(我喜欢为每个绘图打开一个新图形)

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

要使图像更大,请将轴大小设置为图形窗口的 90%

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

注意坐标轴标签对应矩阵元素的索引,所以(1,1)在左上角。

【讨论】:

  • 你好,我正在看,我编辑了我的帖子。我有一个函数。
  • @George: 这个函数f 做了什么?
  • 这是自旋反向运算符。我不知道如何在我的循环中实现它。
  • 而 mlat 只有值 -1 和 1,而不是你说的 0 和 1。我想我有这个权利。
  • @George:哦,我错过了 -1 和 1 的内容。我正在立即编辑。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多