1. <tfoot id='tycmG'></tfoot>
      <i id='tycmG'><tr id='tycmG'><dt id='tycmG'><q id='tycmG'><span id='tycmG'><b id='tycmG'><form id='tycmG'><ins id='tycmG'></ins><ul id='tycmG'></ul><sub id='tycmG'></sub></form><legend id='tycmG'></legend><bdo id='tycmG'><pre id='tycmG'><center id='tycmG'></center></pre></bdo></b><th id='tycmG'></th></span></q></dt></tr></i><div id='tycmG'><tfoot id='tycmG'></tfoot><dl id='tycmG'><fieldset id='tycmG'></fieldset></dl></div>

    2. <legend id='tycmG'><style id='tycmG'><dir id='tycmG'><q id='tycmG'></q></dir></style></legend>

      <small id='tycmG'></small><noframes id='tycmG'>

      • <bdo id='tycmG'></bdo><ul id='tycmG'></ul>
    3. 在给定时间内将频率从 f1 缓慢上升到 f2 的正弦波

      时间:2023-08-03
      <legend id='ozd9G'><style id='ozd9G'><dir id='ozd9G'><q id='ozd9G'></q></dir></style></legend>

        • <bdo id='ozd9G'></bdo><ul id='ozd9G'></ul>
                <tbody id='ozd9G'></tbody>

              <tfoot id='ozd9G'></tfoot>

              <i id='ozd9G'><tr id='ozd9G'><dt id='ozd9G'><q id='ozd9G'><span id='ozd9G'><b id='ozd9G'><form id='ozd9G'><ins id='ozd9G'></ins><ul id='ozd9G'></ul><sub id='ozd9G'></sub></form><legend id='ozd9G'></legend><bdo id='ozd9G'><pre id='ozd9G'><center id='ozd9G'></center></pre></bdo></b><th id='ozd9G'></th></span></q></dt></tr></i><div id='ozd9G'><tfoot id='ozd9G'></tfoot><dl id='ozd9G'><fieldset id='ozd9G'></fieldset></dl></div>

                <small id='ozd9G'></small><noframes id='ozd9G'>

              • 本文介绍了在给定时间内将频率从 f1 缓慢上升到 f2 的正弦波的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在编写一个 c 程序来生成一个正弦波,该正弦波在给定的时间间隔内将频率从 f1 缓慢上升到 f2.

                I'm writing a c program to generate a sinusoidal wave that slowly ramps up frequency from f1 to f2 for a giving time interval.

                我已经编写了这个 c 程序来将频率从 0 提升到 10 Hz,但问题是频率在 360 度完成后会发生变化.如果我尝试在 0 到 360 度之间更改频率,则过渡不平滑且突然.

                I have written this c program to ramp the frequency from 0 to 10 Hz but the problem is that the frequency changes after completion of 360 degrees. If I try to change the frequency between 0 and 360 degree that the transition is not smooth and it is abrupt.

                这是我用过的正弦方程 y = Amplitude*sin(freq*phase)

                This is the equation the sin that I have used y = Amplitude*sin(freq*phase)

                int main(int argc, char *argv[]) {
                
                double y, freq,phase;
                int count; // for convenience of plotting in matlab so all the waves are spread on x axis.
                  for (freq = 0; freq < 10; freq+=1) {
                      for (phase = 0; phase < 360; phase++) { // phase is 360 degrees
                      y = 3 * sin((count*6.283185)+(freq*(phase*(3.14159/180))));   
                    printf("%f %f %f 
                ", freq, phase, y);
                   }
                  count++;
                  }
                return EXIT_SUCCESS;
                }
                

                1. 如何在给定的时间段内平稳地改变频率?
                2. 我应该研究傅立叶变换吗?

                推荐答案

                如果您希望角频率 (w=2 p f) 随时间线性变化,则 dw/dt = aw = w0 + (wn-w0)*t/tn (其中 t 从 0 到 tnw 去从 w0wn).相位是它的积分,所以 phase = w0 t + (wn-w0)*t^2/(2tn) (正如 oli 所说):

                if you want angular frequency (w=2 pi f) to vary linearly with time then dw/dt = a and w = w0 + (wn-w0)*t/tn (where t goes from 0 to tn, w goes from w0 to wn). phase is the integral of that, so phase = w0 t + (wn-w0)*t^2/(2tn) (as oli says):

                void sweep(double f_start, double f_end, double interval, int n_steps) {
                    for (int i = 0; i < n_steps; ++i) {
                        double delta = i / (float)n_steps;
                        double t = interval * delta;
                        double phase = 2 * PI * t * (f_start + (f_end - f_start) * delta / 2);
                        while (phase > 2 * PI) phase -= 2 * PI; // optional
                        printf("%f %f %f", t, phase * 180 / PI, 3 * sin(phase));
                    }
                }
                

                (其中间隔为 tn,增量为 t/tn).

                (where interval is tn and delta is t/tn).

                这是等效 python 代码的输出(5 秒内 1-10Hz):

                here's the output for the equivalent python code (1-10Hz over 5 seconds):

                from math import pi, sin
                
                def sweep(f_start, f_end, interval, n_steps):
                    for i in range(n_steps):
                        delta = i / float(n_steps)
                        t = interval * delta
                        phase = 2 * pi * t * (f_start + (f_end - f_start) * delta / 2)
                        print t, phase * 180 / pi, 3 * sin(phase)
                
                sweep(1, 10, 5, 1000)
                

                顺便说一句,如果你正在听这个(或看着它 - 任何涉及人类感知的东西),我怀疑你不想要线性增长,而是指数增长.但那是 一个不同的问题...

                ps incidentally, if you're listening to this (or looking at it - anything that involves human perception) i suspect you don't want a linear increase, but an exponential one. but that's a different question...

                这篇关于在给定时间内将频率从 f1 缓慢上升到 f2 的正弦波的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:即使浮点数不精确,Excel 如何成功舍入? 下一篇:三次和 catmull 样条对图像的影响

                相关文章

                最新文章

                <i id='ifaDz'><tr id='ifaDz'><dt id='ifaDz'><q id='ifaDz'><span id='ifaDz'><b id='ifaDz'><form id='ifaDz'><ins id='ifaDz'></ins><ul id='ifaDz'></ul><sub id='ifaDz'></sub></form><legend id='ifaDz'></legend><bdo id='ifaDz'><pre id='ifaDz'><center id='ifaDz'></center></pre></bdo></b><th id='ifaDz'></th></span></q></dt></tr></i><div id='ifaDz'><tfoot id='ifaDz'></tfoot><dl id='ifaDz'><fieldset id='ifaDz'></fieldset></dl></div>

              • <legend id='ifaDz'><style id='ifaDz'><dir id='ifaDz'><q id='ifaDz'></q></dir></style></legend>

                <small id='ifaDz'></small><noframes id='ifaDz'>

                  <bdo id='ifaDz'></bdo><ul id='ifaDz'></ul>
              • <tfoot id='ifaDz'></tfoot>