how to create a third column that compute the magnitude from the last two columns

Good Morning,

 

I have a csv file in which the data looks like this,

100000000   -0.2729833998212652     0.9244347613383169
103000000   -0.23913144180817247   0.9332985762452038
106000000   -0.2032334610430953     0.9422111296460353
109000000   -0.16796542891552252   0.9488885572059275
112000000   -0.13186576105870068   0.9539728349394844
115000000   -0.09644751553065327    0.9579449479396245
118000000   -0.060529723509021485   0.96032167904474
121000000   -0.024132389282234785  0.9618425356947005
124000000   0.012135355665699647    0.962002245707421

                                      .

                                      .

                                      .

                                      .

the first column is frequency and the second and the third columns are real and imaginary parts of the complex number. 

I am wondering if there is a way to compute the magnitude from the second and third columns and plot the magnitude vs frequency. Much appreciated! I have also attached the original data file.

0730240001.csv (4.95 KB)

Hi,

First, your csv file is not csv but rather space separated and the column labels contain spaces in the names so that needs to be cleaned up first. That done, I imported your data and have three waves frequency, real, and imaginary. I then create a complex wave of the same length ri is the real part and rw is the imaginary.

Make/N=101/D/C fred

fred =cmplx(ri[p],rw[p])

Make/N=101/D magnitude

magnitude = sqrt(magsqr(fred[p]))

Does this work for you?

Andy

magnitude = cabs(fred)

is simpler. Also, no need for all the explicit [p] indexing.