繁体   English   中英

在Octave中绘制square()和sawtooth()

[英]Plotting square() and sawtooth() in Octave

我试图在Octave中绘制一个方波和一个锯齿波,但它说错了

>>>error: 'sawtooth' undefined near line 17 column 6
error: 'square' undefined near line 17 column 6
>>>error: 'x1' undefined near line 17 column 21
error: evaluating argument list element number 2
>>>error: 'x2' undefined near line 18 column 21
error: evaluating argument list element number 2

然后我在互联网上阅读,并且知道我必须安装一些软件包。 我安装了必要的包以及它们各自的依赖项。 尽管如此,它并没有什么不同。 同样的错误仍然存​​在。 然后我安装了在线存储库中的所有软件包。 再一次没有区别。

我在Matlab中运行相同的代码并且它有效! (我知道它与所有软件包捆绑在一起)。

但我真的没有遇到我在Octave面临的问题。 我使用QtOctave接口,有一个选项来安装包。 有没有办法检查已安装的软件包? 他们真的安装了吗?

我在FreeMat中尝试了相同的代码,它也有一些错误。

这是我的代码:

% program to plot a saw tooth and square wave
fs = 10000;
t = 0:1/fs:1.5;
x1 = sawtooth(2*pi*50*t);
x2 = square(2*pi*50*t);
subplot(211);plot(t,x1);axis([0 0.2 -1.2 1.2]);
xlabel('Time (sec)');ylabel('Amplitude');title('Sawtooth Periodic Wave');
subplot(212);plot(t,x2);axis([0 0.2 -1.2 1.2]);
xlabel('Time (sec)');ylabel('Amplitude');title('Square Periodic Wave');
set(gcf,'Color',[1 1 1]);

请帮助我将此代码用于Octave。

适合我。 请参阅https://saturnapi.com/fullstack/plotting-square-and-sawtooth-in-octave

如果你正在使用Ubuntu,请确保安装必要的包a la

sudo apt-get -q -y install octave-signal

在此输入图像描述

你真的加载了感兴趣的包吗? 即使安装了软件包,它们也可能无法加载到您的特定Octave会话中。 您可以通过在Octave提示符下键入pkg load <package_name>替换<package_name> ,并使用相应的paccage名称。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM