一、安裝相關軟件
- 在Windows中安裝VirtualBox;
- 在VirtualBox中安裝Ubuntu Server;
- 在Ubuntu Server中安裝cifs-utils:sudo apt-get install cifs-utils;
- 在Ubuntu Server中安裝Octave:sudo apt-get install octave transfig epstool。
二、在Windows和Ubuntu Server之間建立共享目錄
- 在Windows中共享一個share文件夾,網絡權限和目錄全限全部設爲Everyone & Full control;
- 在Ubuntu Server中建立映射目錄:sudu mkdir /mnt/share;
- 在Ubuntu Server中掛載網絡驅動器:sudo mount -t cifs //主機IP/share /mnt/share -o username=主機用戶名;
- 在Ubuntu Server中的/home目錄下建立快捷鏈接:ln -s /mnt/share/ ~/share/。
三、繪圖
- 在Windows中編寫matlab繪圖代碼文件,放到共享文件夾中,例如文件test.m;
- 繪圖代碼中,plot語句的下面要將圖像輸出到文件:print -dpng myfig.png;
- 在Ubuntu Server中切換到共享目錄:cd ~/share;
- 以靜默方式運行octave:sudo octave -q test.m;
- 在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