发布日期:2020年7月4日
我想知道是否有人知道如何绘制一个正弦波,比如说振幅为0.1作为开始,然后像往常一样继续。直到某一点,振幅变为1.0。就像振幅的突然变化。就像我是一个稳定的振荡系统,在某一点上变得不稳定。我期待的情节如下:
问候,, 茴香
更新进度:18/4/2020
import numpy as np
import matplotlib.pyplot as plotter
from scipy import signal
# How many time points are needed i,e., Sampling Frequency
samplingFrequency = 1500
# At what intervals time points are sampled
samplingInterval = 1 / samplingFrequency;
# Begin time period of the signals
beginTime = 0;
# End time period of the signals
endTime = 0.3;
# Frequency of the signals
signal1Frequency = 50;
#Time points
time = np.arange(beginTime, endTime, samplingInterval);
phase = 180
pi = np.pi
phi = phase*pi/180
# Create two waves- sine and square
amplitude1 = np.sin(2*np.pi*signal1Frequency*time)
amplitude2 = signal.square(2 * np.pi * 50 * time+ phi )
figure, axis = plotter.subplots(1, 1)
plotter.subplots_adjust(hspace=1)
if (time >0.2):
amplitude = 3*amplitude1
plotter.plot(time, amplitude)
plotter.title('test')
plotter.show()
以上是我目前正在编写的代码。由于模棱两可,它不断地弹出一个错误。要求我使用.all()和.any()函数来解决它。当我这么做的时候,我并没有得到我期望的喘振点。有什么想法吗?我使用时间作为x轴,而不是索引。我用numoysine代替了数学库。这是因为当我尝试对下面提出的代码进行FFT时,我得到的不是50 Hz,而是30或10 Hz,这是可以理解的,因为没有设置频率,它取决于正弦本身创建的周期周期
问候,, 茴香
您可以绘制一个分段
sin
函数,其中第二部分定义发生的喘振,您可以在此处更改振幅例如:
您将获得:
我已将代码转换为时段时间:
结果
就像一个正弦波在现实中,如果振幅变化。你在改变之前和之后连接振幅的点。这和绘制正弦波本身没有什么不同。它的外观,例如锐利的边缘,只取决于变化发生的时刻
这是计算点和绘制点与点之间的线的一种非常基本的方法
当x=5时,振幅加倍
在对其进行进一步构造并将所需的振幅变化放入列表后,很容易产生漂亮的尖峰
相关问题 更多 >
编程相关推荐