天天看點

Matlab畫圖導出Latex論文插圖

f=figure;

subplot(2,1,1);
plot(t,zeros(1,1001),'k:','LineWidth',1.2);%參考值用黑色點線
hold on
plot(t,xn,'--','LineWidth',1.2);%用虛線,線粗一點
hold on 
plot(t,x,'LineWidth',1.4);%重要的資料用實線,線粗一點
legend('$x_{r}$','$x_n$','$x$','Interpreter','latex')%這樣出來的字型是latex字型
axis([0 10 -0.1 0.3]);
xlabel('$Time(s)$','Interpreter','latex');ylabel('$x$','Interpreter','latex');

subplot(2,1,2);
plot(t,zeros(1,1001),'k:','LineWidth',1.2);
hold on
plot(t,[un un(1000)],'--','LineWidth',1.2);
hold on
plot(t,[u u(1000)],'LineWidth',1.4);
legend('$u_{r}$','$u_n$','$u$','Interpreter','latex');
axis([0 10 -0.5 0.5]);
xlabel('$Time(s)$','Interpreter','latex');ylabel('$u$','Interpreter','latex');


print(f,'Evolution','-depsc','-r600'); % 設定圖檔格式、分辨率
savefig(f,'Evolution.fig')
           

效果

Matlab畫圖導出Latex論文插圖

 也可以在圖窗裡打開屬性編輯器進行修改,感覺改完效果好點

Matlab畫圖導出Latex論文插圖

修改完選擇另存為eps格式,在latex中使用代碼添加圖檔

\begin{figure}
    \centering
    \includegraphics[width=0.5 \textwidth]{Evolution.eps}
    \caption{Evolution}
\end{figure}
           

latex文檔開頭要添加包

\usepackage{graphicx}
\usepackage{epstopdf}
           

繼續閱讀