Matlab 到 Latex 数据超出内存限制错误

Matlab 到 Latex 数据超出内存限制错误

有时我觉得使用 Matlab 绘制图形更容易,但我将它们保存到数据文件中,然后在 Latex 中绘制它们以具有相同的字体样式、颜色等。但我遇到了几个这样的问题。我使用在线提供的 matlab 代码来比较不同的过滤器,我保存了如下所示的输出

n = 5;
f = 2e9;

[zb,pb,kb] = butter(n,2*pi*f,'s');
[bb,ab] = zp2tf(zb,pb,kb);
[hb,wb] = freqs(bb,ab,4096);
[z1,p1,k1] = cheby1(n,3,2*pi*f,'s');

[b2,a2] = zp2tf(z2,p2,k2);
[h2,w2] = freqs(b2,a2,4096);
[ze,pe,ke] = ellip(n,3,30,2*pi*f,'s');
[be,ae] = zp2tf(ze,pe,ke);
[he,we] = freqs(be,ae,4096);

plot(wb/(2e9*pi),mag2db(abs(hb)))
hold on
plot(w1/(2e9*pi),mag2db(abs(h1)))

plot(we/(2e9*pi),mag2db(abs(he)))
axis([0 4 -40 5])
grid
xlabel('Frequency (GHz)')
ylabel('Attenuation (dB)')
legend('Butterworth','Chebyshev','Elliptic')


[zb,pb,kb] = besself(n,2*pi*f,'low');
[bb,ab] = zp2tf(zb,pb,kb);
[hb1,wb1] = freqs(bb,ab,4096);

hold on
plot(wb1/(2e9*pi),mag2db(abs(hb1)))
dataOut1=[wb/(2e9*pi) mag2db(abs(hb))];

save('filter1.dat','dataOut1', '-ascii')
dataOut2=[w1/(2e9*pi) mag2db(abs(h1))];
save('filter2.dat','dataOut2', '-ascii')
dataOut3=[we/(2e9*pi) mag2db(abs(he))];

save('filter3.dat','dataOut3', '-ascii')
dataOut4=[wb1/(2e9*pi) mag2db(abs(hb1))];

save('filter4.dat','dataOut4', '-ascii')

然后我在 Latex 中使用此代码读取数据并绘图,但出现有关内存限制的错误,我该如何解决这个问题。我还想知道是否有办法将数据保存在文件夹中,然后将路径提供给 Latex 以读取它。

\begin{tikzpicture}
\begin{axis}
\pgfplotstableread{filter1.dat}\datatable
\addplot table {\datatable};
\addplot table[y index=1] {\datatable};
\pgfplotstableread{filter2.dat}\datatable
\addplot table {\datatable};
\addplot table[y index=1] {\datatable};
\pgfplotstableread{filter3.dat}\datatable
\addplot table {\datatable};
\addplot table[y index=1] {\datatable};
\pgfplotstableread{filter4.dat}\datatable
\addplot table {\datatable};
\addplot table[y index=1] {\datatable};

\legend{$\nu=0$, $\nu=1$, $\nu=2$, $\nu=3$}

\end{axis}
\end{tikzpicture}

相关内容