简体   繁体   English

如何创建振幅上下限的正弦波

[英]How to create a sin wave with upper and lower amplitude bounds

I can't for the life of my wrap my head around this seemingly easy problem. 我一生都无法解决这个看似简单的问题。

I am trying to create a sine wave with upper and lower bounds for the amplitude (ie. highest point is 3 and lowest point is 0.4) 我正在尝试创建一个振幅上下限的正弦波(即最高点为3,最低点为0.4)

Using regular math I am able to get a sine wave in an array from 1 to -1 but I don't know how to change those bounds. 使用常规数学,我能够在从1到-1的数组中获得正弦波,但是我不知道如何更改这些界限。

    static int MAX_POINTS = 100;
static int CYCLES = 1;
static double[] list = new double[100];

 public static void SineCurve()
  {
    double phaseMultiplier = 2 * Math.PI * CYCLES / MAX_POINTS; 
    for (int i = 0; i < MAX_POINTS; i++)
    {
      double cycleX = i * phaseMultiplier;
      double sineResult = Math.sin(cycleX);
      list[i]= sineResult;

    }

    for(int i=0;i<list.length;i++){
        System.out.println(list[i]);
    }
  }

Any tips would be greatly appreciated. 任何提示将非常感谢。

The amplitude (multiplier of sin(x) value) is half the difference between the highest and lowest values you want. 幅度(sin(x)值的倍数)是所需的最高值和最低值之差的一半。 In your case 就你而言

amplitude = (3 - 0.4)/2

which is 1.3 . 1.3 Then zero offset is the lowest value plus the amplitude, which makes it 1.7 in your case. 然后零偏移是最小值加上振幅,在您的情况下为1.7

The equation you want to graph is then 然后要绘制的方程式是

1.3 * sin(x) + 1.7

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

相关问题 如何获取Z3 java API中的上限和下限? - How to get the upper bounds and lower bounds in Z3 java API? 了解上界和下界 ? 在 Java 泛型中 - Understanding upper and lower bounds on ? in Java Generics 具有下限和上限的Apache Commons Math SimplexSolver? - Apache Commons Math SimplexSolver with lower and upper bounds? Java浮动到双 - 上限和下限? - Java float to double - upper and lower bounds? Spark SQL为JDBC查询生成错误的上下限 - Spark SQL Generating Wrong Upper and Lower Bounds for JDBC Queries 你能定义一个具有下限和上限的泛型边界吗? - Can you define a generic bound that both has lower and upper bounds? 是否可以在Mersenne Twister RNG(Java)中为nextInt指定上限和下限 - Is it possible to specify the upper and lower bounds for nextInt in Mersenne Twister RNG (Java) 检索和解码调幅 sin - Retrieving and decoding amplitude modulated sin 如何在Java中创建同时支持大写和小写E作为指数分隔符的NumberFormat? - How to create a NumberFormat in Java that supports both an upper-case and a lower-case E as an Exponent Separator? 我如何创建一个程序来过滤字符串中的小写和大写字母? - how do i create a program to filter out lower case and upper case letters from a string?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM