Windows下繪製數學函數圖像的方法

一、安裝相關軟件

  1. 在Windows中安裝VirtualBox;
  2. 在VirtualBox中安裝Ubuntu Server;
  3. 在Ubuntu Server中安裝cifs-utils:sudo apt-get install cifs-utils;
  4. 在Ubuntu Server中安裝Octave:sudo apt-get install octave transfig epstool。


二、在Windows和Ubuntu Server之間建立共享目錄

  1. 在Windows中共享一個share文件夾,網絡權限和目錄全限全部設爲Everyone & Full control;
  2. 在Ubuntu Server中建立映射目錄:sudu mkdir /mnt/share;
  3. 在Ubuntu Server中掛載網絡驅動器:sudo mount -t cifs //主機IP/share /mnt/share -o username=主機用戶名;
  4. 在Ubuntu Server中的/home目錄下建立快捷鏈接:ln -s /mnt/share/ ~/share/。


三、繪圖

  1. 在Windows中編寫matlab繪圖代碼文件,放到共享文件夾中,例如文件test.m;
  2. 繪圖代碼中,plot語句的下面要將圖像輸出到文件:print -dpng myfig.png;
  3. 在Ubuntu Server中切換到共享目錄:cd ~/share;
  4. 以靜默方式運行octave:sudo octave -q test.m;
  5. 在Windows中可以看到共享目錄下多了一個myfig.png,就是函數圖像。

 一個測試例程:

x = 0:pi/100:2*pi;
y = tan(x);
plot(x,y);
print -dpng xab.png;

 

附更改控制檯分辨率方法:
編輯配置文件,執行命令:sudo vi /etc/default/grub
GRUB_GFXMODE=1024x768x24
GRUB_CMDLINE_LINUX_DEFAULT="splash xvga=1024x768x24 consoleblank=0"
# splash:開機和關機時顯示圖形畫面
# xvga=1024x768x24:屏幕分辨率和顏色深度
# consoleblank=0:禁用屏保
保存後執行命令:sudo update-grub2

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章