Is it possible to plot a graph for complex values? There is, for example, an array of 1000 elements.
How to build a graph for it?
#include "graph.h" #include "ui_graphwindow.h" #include <random> #include <complex> #define size 1000 #define mean 0. #define sigma 1. #define width 10000. using namespace std; static random_device rd; static mt19937 gen(rd()); double normalComplex() { normal_distribution <double> normal(mean, sigma); double normalComplex = normal(gen); return normalComplex; } graph::graph(QWidget *parent) : QMainWindow(parent), ui(new Ui::graph) { ui->setupUi(this); complex <double> graph1[size], graph2[size],graph3[size]; int numbers[size], zero[size]; for (int i = 1; i <= size; i++){ numbers[i] = i; zero[i] = 0; } double x = 1, temporaryDelay = 1 / width * 10000.; complex <double> ck1 (normalComplex(), normalComplex()), ck2 (normalComplex(), normalComplex()), w (normalComplex(), normalComplex()); for (int i = 0; i <= size; i++){ graph1[i] = 0.9 * ck1 + w; graph2[i] = 0.9 * ck2 + w; if(i != temporaryDelay) graph3[i] = x * graph2[i] + w; else graph3[i] = x * graph1[i] + x * graph1[i] + w; } } graph::~graph() { delete ui; }
You need to build graphs: graph 1, graph 2, graph3
Plotting in python
plt.figure() plt.subtitle(2, 2, 1) plot.graph(numbers, graph 1, label='graph1') plot.graph (numbers, zero, color = 'black')