Magdalena
Magdalena

Reputation: 38

How to Plot Fftw in Xcode?

I need to plot the graph of Fftw in my application. I saved the result ( fft_result[i][0] and fft_result[i][1]) in two NSMutableArray and I am using the APLGraphView to plot in. I was ploting the raw data like this:

[[weakSelf.graphViews objectAtIndex:kDeviceMotionGraphTypeUserAcceleration] addX:deviceMotion.userAcceleration.x y:deviceMotion.userAcceleration.y z:deviceMotion.userAcceleration.z];

And I thought I could do it for the fftw too:

for( i = 0 ; i < SIZE ; i++ ) {
                    NSLog(@"FFTW-X [%d]: %f , %f ",i, fft_result[i][0], fft_result[i][1] );

                    fft_result[i][0]=[ arrayFftwX[i] floatValue];
                    fft_result[i][1]=[ arrayFftwXx[i] floatValue];
                    [[weakSelf.graphViews objectAtIndex:kDeviceMotionGraphTypeFftwX] addX:arrayFftwX[i] y:arrayFftwXx[i] z:0];

Can somebody help me here? Every help would be greatly appreciated.

Magda

Upvotes: 1

Views: 96

Answers (1)

josef
josef

Reputation: 1632

Your code should be like this:

[[weakSelf.graphViews objectAtIndex:kDeviceMotionGraphTypeFftwX] 
addX:fft_result[i][0] y:fft_result[i][1] z:4 ]; // fft_result[i][0] its for the Re-output, fft_result[i][1] for the Im-output and z=4 . its better than 0. So you can see the other values.

Upvotes: 1

Related Questions