繁体   English   中英

显示整数数组不起作用

[英]Displaying an array of integers does not work

我有以下代码用于通过检测QRS峰值从ECG信号计算心律:

public class Heart_Rate {

public static void main(String[] args) throws IOException{
    // Read Text file
    Path filePath = Paths.get("heartrate.txt");
    Scanner scanner = new Scanner(filePath);
    List<Double> rawData = new ArrayList<Double>();

    while (scanner.hasNext()) {
        if (scanner.hasNextDouble()) {
            rawData.add(scanner.nextDouble());
        } else {
            scanner.next();
        }
    }
    System.out.println(rawData);

    //Find Max value for Threshold Level
    Double maximum = Collections.max(rawData);
    Double threshold = 0.7*maximum;

    System.out.println("Maximum = " + maximum);
    System.out.println("Threshold = " + threshold);

    //Calculate Heart Rate from list "Raw Data"
    int upflag = 0;
    int last = 1;
    int p = 0;
    int t = 0;
    int count = 0;
    //List<Double> heartRate = new ArrayList<Double>();
    int heartRate2[] = new int[50];

    for (int i = 0; i < rawData.size(); i++) {
        if (rawData.get(i)> threshold){
            if (upflag == 0){
                if (last > 0){
                    t = i - last;
                    p = 100*60/t;
                    //100 is the sampling rate
                    heartRate2[count] = p;
                    count = count + 1;
                    //heartRate.add(p);

                }
                last = i;
            }
            upflag = 50;
        }
        else {
            if (upflag > 0){
                upflag = upflag -1;
            }
        }
    }
    System.out.println("Count = " + count);
    System.out.println("Heart Rate = " + heartRate2);
    System.out.println("Heart Rate = " + heartRate2);

    }


}

当我将计算出的心率值(p)添加到ArrayList(称为HeartRate)时,我收到了一个适当的值数组。 但是,我尝试将所有值都更改为int并将其值保存在一个整数数组中(称为heartRate2),我得到以下结果:心率= [I @ dd1e765我需要将我的值设为整数,因为心率是按心跳计算的每分钟。 我还尝试将double值转换为int,但最终收到与上述类似的结果。

使用Arrays.toString(arr)为某些数组arr获取有意义的String表示形式。

暂无
暂无

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

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