Dank Michael, ist der Error weg. aber mein Code ( in der Zeile: 51) zeichnet der Data fftw_result ohne aufzuhören . Wie kann ich die nur einmal zeichne?
Ich bin mit dem App. fast fertig. Hier ist ein stuck meines Codes:
Alles anzeigen
Jede Hilfe can mir wert sein. Sieht jemand dass ich was ändern soll dann bitte bescheid sagen.
P.s.: meine Applikation soll die Beschleunigungsdaten zeichnen und durch FFTW filtern und noch mal zeichnen.
Danke.
josef
Ich bin mit dem App. fast fertig. Hier ist ein stuck meines Codes:
Quellcode
- int SIZE =64;
- NSMutableArray *arrayFftwXRe= [NSMutableArray arrayWithCapacity:SIZE]; ...
- NSTimeInterval delta = 0.005;
- NSTimeInterval updateInterval = deviceMotionMin + (delta * sliderValue);
- NSMutableArray *sensorData= [NSMutableArray arrayWithCapacity:SIZE]; ...
- if ([mManager isDeviceMotionAvailable] == YES) {
- [mManager setDeviceMotionUpdateInterval:updateInterval];
- [mManager startDeviceMotionUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMDeviceMotion *deviceMotion, NSError *error) {
- // saving data
- NSString *strSensorData = [NSString stringWithFormat:@"%.6f %.6f %.6f %.6f ", deviceMotion.timestamp, deviceMotion.userAcceleration.x, deviceMotion.userAcceleration.y, deviceMotion.userAcceleration.z];
- NSString *strSensorDataX = [NSString stringWithFormat:@"%.6f %.6f ", deviceMotion.timestamp, deviceMotion.userAcceleration.x];
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *docDir = [paths objectAtIndex: 0];
- NSString *docFile = [docDir stringByAppendingPathComponent: @"sensordata.txt"];
- NSString *docFileX = [docDir stringByAppendingPathComponent: @"dataFFTWX.txt"];
- if (![fileManager fileExistsAtPath:docDir]){
- [fileManager createFileAtPath:docFile
- contents:nil
- attributes:nil];
- [fileManager createFileAtPath:docFileX
- contents:nil
- attributes:nil];
- }
- [ sensorData.description writeToFile:docFile atomically:YES encoding:NSUTF8StringEncoding error:nil];
- /////////////////////////////////////// FFTW
- fftw_complex *data, *fft_result;
- fftw_plan plan_forward;
- int i;
- data = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * SIZE);
- fft_result = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * SIZE);
- plan_forward = fftw_plan_dft_1d(SIZE, data, fft_result,
- FFTW_FORWARD, FFTW_ESTIMATE);
- /////////////////////////////////////// Data-X-Y-Z /////////////////
- switch (weakSelf.segmentedControl.selectedSegmentIndex) {
- case kDeviceMotionGraphTypeUserAcceleration:
- [weakSelf setLabelValueX:deviceMotion.userAcceleration.x y:deviceMotion.userAcceleration.y z:deviceMotion.userAcceleration.z];
- // userAcceleration
- [[weakSelf.graphViews objectAtIndex:kDeviceMotionGraphTypeUserAcceleration] addX:deviceMotion.userAcceleration.x y:deviceMotion.userAcceleration.y z:deviceMotion.userAcceleration.z];
- break;
- /////////////////////////////////////// Data-X ////////////////////
- case kDeviceMotionGraphTypeFftwX:
- for( i = 0 ; i < SIZE ; i++ ) {
- data[i][0] = [sensorDataX[i] floatValue];
- data[i][1] = 0.0;
- }
- fftw_execute( plan_forward );
- for( i = 0 ; i < SIZE ; i++ ) {
- [arrayFftwXRe addObject:@(fft_result[i][0])];
- }
- [weakSelf setLabelValueX:fft_result[i][0] y:fft_result[i][1] z:deviceMotion.userAcceleration.z];
- [[weakSelf.graphViews objectAtIndex:kDeviceMotionGraphTypeFftwX] addX:fft_result[i][0] y:4 z:4];
- [ arrayFftwXRe.description writeToFile:docFileX atomically:YES encoding:NSUTF8StringEncoding error:nil];
- break;
Jede Hilfe can mir wert sein. Sieht jemand dass ich was ändern soll dann bitte bescheid sagen.
P.s.: meine Applikation soll die Beschleunigungsdaten zeichnen und durch FFTW filtern und noch mal zeichnen.
Danke.
josef
Dieser Beitrag wurde bereits 10 mal editiert, zuletzt von josef907 ()