Pages: [1]   Go Down
Author Topic: Complex number printing  (Read 700 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How can I do a Serial.println() for an array variable which has been delared as a complex number?

the code below provides me with the following errors

sketch_oct05a.ino: In function 'void loop()':
sketch_oct05a:22: error: no matching function for call to 'UARTClass::println(complex&)'
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:67: note: candidates are: size_t Print::println(const __FlashStringHelper*)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:68: note:                 size_t Print::println(const String&)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:69: note:                 size_t Print::println(const char*)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:70: note:                 size_t Print::println(char)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:71: note:                 size_t Print::println(unsigned char, int)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:72: note:                 size_t Print::println(int, int)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:73: note:                 size_t Print::println(unsigned int, int)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:74: note:                 size_t Print::println(long int, int)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:75: note:                 size_t Print::println(long unsigned int, int)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:76: note:                 size_t Print::println(double, int)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:77: note:                 size_t Print::println(const Printable&)
C:\arduino-1.5.2\arduino-1.5.2\hardware\arduino\sam\cores\arduino/Print.h:78: note:                 size_t Print::println()

Code:
//   Include FFT header
#include "librowfft.h"
#include <stdio.h>
#include <complex.h>


complex *pSignal = new complex[1024];
int Mysignal;

void setup() {
  Serial.begin(57600);
}

void loop() {
  for (int i=0;i<1024;i++){
  pSignal[i]=analogRead(0);
  }
  CFFT::Forward(pSignal, 1024);
 
 for (int p=0;p<1024;p++){
    Serial.println(pSignal[p]);
 }

  Serial.println("fftdone");
  //}
  delay(10000);
}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 650
Posts: 50833
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How can I do a Serial.println() for an array variable which has been delared as a complex number?
What is a complex? A link to the library is needed.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26616
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
complex *pSignal = new complex[1024];
int Mysignal;
That's a lot of RAM - what are you running this on?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Edison Member
*
Karma: 33
Posts: 1477
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is probably not included for space reasons. You will have to roll your own. Like AWOL hinted at, if you are going to do lots of complex arithmetic, you probably need to rethink your processor approach.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14007
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

FYI my complex lib supports Serial.println()

see - https://github.com/RobTillaart/Arduino/tree/master/libraries/Complex - for the last version.

You can use it as an example how to build print support into your complex lib too.

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: