2

I have used Matlab to plot a bode diagram of a transfer function. After plotting I used matlab2tikz() to export it as a *.tikz file. I then imported the bode diagram in Latex by using

\begin{figure}
    \centering
    \input{Figures/matlab.tikz}
    \caption{Test.}
    \label{fig:vector}
\end{figure}

The *.tikz file is given in the following code-box.

    % This file was created by matlab2tikz.
%
%The latest updates can be retrieved from
%  http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz-matlab2tikz
%where you can also make suggestions and rate matlab2tikz.
%
\definecolor{mycolor1}{rgb}{0.00000,0.44700,0.74100}%
%
\begin{tikzpicture}

\begin{axis}[%
width=4.396in,
height=1.713in,
at={(0.883in,2.125in)},
scale only axis,
%separate axis lines,
every outer x axis line/.append style={white!40!black},
every x tick label/.append style={font=\color{white!40!black}},
every x tick/.append style={white!40!black},
xmode=log,
xmin=0.01,
xmax=100,
xtick={0.01,0.1,1,10,100},
xticklabels={\empty},
xminorticks=true,
every outer y axis line/.append style={white!40!black},
every y tick label/.append style={font=\color{white!40!black}},
every y tick/.append style={white!40!black},
ymin=-40,
ymax=0,
ylabel={Magnitude (dB)},
axis background/.style={fill=white},
xmajorgrids,
xminorgrids,
ymajorgrids
]
\addplot [color=mycolor1, forget plot]
  table[row sep=crcr]{%
1e-20   -13.9794000867204\\
1e-17   -13.9794000867204\\
1e-12   -13.9794000867204\\
1e-08   -13.9794000867204\\
1e-05   -13.9794000849658\\
0.001   -13.9793825412582\\
0.01    -13.9776458860589\\
0.0116808447054201  -13.9770067914112\\
0.0136442133032142  -13.9761349464558\\
0.0159375936722473  -13.9749456606442\\
0.0186164556663607  -13.973323491043\\
0.0217455927604098  -13.9711111305876\\
0.0254006892061656  -13.9680943284909\\
0.0296701506027862  -13.9639814664422\\
0.0346572421577573  -13.9583759716628\\
0.0404825863562903  -13.9507391934119\\
0.0472870804501588  -13.9403407027084\\
0.0552353043311014  -13.9261922266959\\
0.0645195012148216  -13.9069606950538\\
0.0753642274161497  -13.8808553753637\\
0.0880317836792013  -13.845484243795\\
0.102828559429789   -13.7976763651812\\
0.120112443398143   -13.7332714387449\\
0.140301479852228   -13.6468866949827\\
0.163883979809451   -13.5316872774223\\
0.19143033178604    -13.3792107644952\\
0.223606797749979   -13.179328182129\\
0.26119162795938    -12.9204541304589\\
0.305093884454939   -12.5901276002351\\
0.356375428489154   -12.1760434253993\\
0.416276603700937   -11.6675009063371\\
0.486246236233036   -11.0570727222389\\
0.567976677403314   -10.3421764986871\\
0.663444736504862   -9.52628938903971\\
0.707106781186548   -9.16453948549925\\
0.774959493774169   -8.61986539918777\\
0.905218149976707   -7.64153600751612\\
1.05737126344056    -6.62069584824435\\
1.23509895242231    -5.60273239858668\\
1.44269990590721    -4.65705193995413\\
1.68519535574264    -3.88365008570123\\
1.96845052487251    -3.40516610485184\\
2.29931648913385    -3.32867180812183\\
2.68579588381844    -3.68984035841301\\
3.13723646293398    -4.43277253714555\\
3.66455719277134    -5.44980543410073\\
4.28051234828925    -6.635988664332\\
5   -7.91558643561433\\
5.84042235271007    -9.24243182850254\\
6.82210665160709    -10.5910983157716\\
7.96879683612363    -11.9485256514505\\
9.30822783318035    -13.3084182737452\\
10.8727963802049    -14.6679856855673\\
12.7003446030828    -16.0261726634693\\
14.8350753013931    -17.3827373913773\\
17.3286210788787    -18.7377868672546\\
20.2412931781451    -20.0915513210191\\
23.6435402250794    -21.4442805967028\\
27.6176521655507    -22.7962011730798\\
32.2597506074108    -24.1475022456641\\
37.6821137080748    -25.4983349069581\\
44.0158918396006    -26.8488165555981\\
51.4142797148945    -28.1990368063813\\
60.0562216990716    -29.5490632552764\\
70.1507399261138    -30.8989464724903\\
81.9419899047252    -32.2487240734988\\
95.7151658930202    -33.5984239234661\\
111.803398874989    -34.9480666042162\\
1118.03398874989    -54.9484958739243\\
111803.398874989    -94.9485002163667\\
111803398.874989    -154.948500216801\\
1118033988749.89    -234.948500216801\\
1.11803398874989e+17    -334.948500216801\\
1e+20   -393.97940008672\\
};
\end{axis}

\begin{axis}[%
width=4.396in,
height=1.519in,
at={(0.883in,0.481in)},
scale only axis,
separate axis lines,
every outer x axis line/.append style={white!40!black},
every x tick label/.append style={font=\color{white!40!black}},
every x tick/.append style={white!40!black},
xmode=log,
xmin=0.01,
xmax=100,
xminorticks=true,
every outer y axis line/.append style={white!40!black},
every y tick label/.append style={font=\color{white!40!black}},
every y tick/.append style={white!40!black},
ymin=-91.35,
ymax=46.35,
ytick={-90, -45,   0,  45},
ylabel={Phase (deg)},
axis background/.style={fill=white},
xmajorgrids,
xminorgrids,
ymajorgrids
]
\addplot [color=mycolor1, forget plot]
  table[row sep=crcr]{%
1e-20   6.36110936292703e-15\\
1e-17   6.36110936292703e-15\\
1e-12   8.0200866847784e-11\\
1e-08   8.02140896858168e-07\\
1e-05   0.000802140913034469\\
0.001   0.0802139357797426\\
0.01    0.801985410920095\\
0.0116808447054201  0.936720531982547\\
0.0136442133032142  1.09406326564116\\
0.0159375936722473  1.27779030935816\\
0.0186164556663607  1.49229936495085\\
0.0217455927604098  1.74270536055411\\
0.0254006892061656  2.03494804181918\\
0.0296701506027862  2.37591003800292\\
0.0346572421577573  2.77354274741579\\
0.0404825863562903  3.23699443627163\\
0.0472870804501588  3.77673014713627\\
0.0552353043311014  4.40462540732662\\
0.0645195012148216  5.13400397239799\\
0.0753642274161497  5.97957219145069\\
0.0880317836792013  6.95717705395815\\
0.102828559429789   8.08327994670281\\
0.120112443398143   9.37399385216116\\
0.140301479852228   10.8434833322363\\
0.163883979809451   12.5014895116821\\
0.19143033178604    14.3497487474691\\
0.223606797749979   16.3771772646817\\
0.26119162795938    18.5539595523163\\
0.305093884454939   20.8251391593456\\
0.356375428489154   23.1048831561193\\
0.416276603700937   25.2729874166241\\
0.486246236233036   27.1749543740649\\
0.567976677403314   28.6257949620513\\
0.663444736504862   29.4158912748297\\
0.707106781186548   29.4962084965664\\
0.774959493774169   29.3159265157783\\
0.905218149976707   28.0785331851269\\
1.05737126344056    25.4382313068369\\
1.23509895242231    21.1197189270127\\
1.44269990590721    14.8785142782225\\
1.68519535574264    6.61001975654252\\
1.96845052487251    -3.46431606401817\\
2.29931648913385    -14.6496243963203\\
2.68579588381844    -25.9068841477412\\
3.13723646293398    -36.2808842592017\\
3.66455719277134    -45.2473951426616\\
4.28051234828925    -52.7161803707307\\
5   -58.8406954916556\\
5.84042235271007    -63.8499642138747\\
6.82210665160709    -67.9634197692201\\
7.96879683612363    -71.3632059747551\\
9.30822783318035    -74.1923299712252\\
10.8727963802049    -76.561103868503\\
12.7003446030828    -78.5546851745658\\
14.8350753013931    -80.2394519895968\\
17.3286210788787    -81.6678401073458\\
20.2412931781451    -82.881858416139\\
23.6435402250794    -83.9156079911711\\
27.6176521655507    -84.7970899742155\\
32.2597506074108    -85.549517095129\\
37.6821137080748    -86.1922807627092\\
44.0158918396006    -86.7416780234543\\
51.4142797148945    -87.2114691142072\\
60.0562216990716    -87.613313482543\\
70.1507399261138    -87.9571168609165\\
81.9419899047252    -88.2513118253988\\
95.7151658930202    -88.5030875251639\\
111.803398874989    -88.7185797659132\\
1118.03398874989    -89.8718824944919\\
111803.398874989    -89.9987188274216\\
111803398.874989    -89.9999987188274\\
1118033988749.89    -89.9999999998719\\
1.11803398874989e+17    -90\\
1e+20   -90\\
};
\end{axis}

\begin{axis}[%
width=4.521in,
height=3.566in,
at={(0.758in,0.481in)},
scale only axis,
xmin=0,
xmax=1,
xtick={\empty},
xlabel={Frequency  (rad/s)},
ymin=0,
ymax=1,
ytick={\empty},
axis line style={draw=none},
ticks=none,
title style={font=\bfseries},
title={Bode Diagram},
axis x line*=bottom,
axis y line*=left
]
\end{axis}
\end{tikzpicture}%

I was able to import the picture correctly, but there are two lines that are not what I have expected (marked yellow). It seems like a box. I would be glad if someone could tell me how I can remove these lines.

enter image description here

1

I solved the problem. When using matlab2tikz() the created *.tikz file needs to be changed. At the end of the file an additional axis was created. I deleted the additional two additional statements

axis x line*=bottom,
axis y line*=left,

this solved the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.