Sponsored Content
Full Discussion: Calculate root mean square?
Top Forums Shell Programming and Scripting Calculate root mean square? Post 302954481 by liuzhencc on Tuesday 8th of September 2015 10:48:22 AM
Old 09-08-2015
Calculate root mean square?

Dear friend,

I know for a single case, this could be finished quickly with Excel. But if we have hundreds of files, we definitely want to do it with a script or a FORTRAN code. Since I have no knowledge of FORTRAN, I tried to work out a script to do it. The math is very simple. we chose one atom (in x, y, z, Cartesian coordinate), and we calculate the distance from other atom to the reference atom with the simple math sqrt((x(i)-x(1))^2+(y(i)-y(1))^2+(z(i)-z(1))^2)
Problem explanation: we have a list of numbers
Code:
P               1.219142       0.637315      -0.824280
N              -0.265369       0.551699      -1.665314
P              -1.232957      -0.291982      -0.536350
C               1.550001       2.370502      -0.242803
C               0.756639       2.983923       0.747041
C               1.003518       4.293274       1.173466
C               2.045233       5.026004       0.616725
C               2.835510       4.452541      -0.372444
C               2.587869       3.143957      -0.800209
C               2.645951       0.045340      -1.859172

assume we set the P1 as the center atom, now we need to calculate all the distance of other atoms from P, respectively.
and we print out the results as follows,
Code:
N2-P1 P3-P1 C4-P1 C5-P1 C6-P1 C7-P1 C8-P1 C9-P1 C10-P1
1.708 2.638 1.858  2.862 4.172  4.692 4.168 2.856 1.859

Thank you very much in advance!
Zhen

Last edited by liuzhencc; 09-08-2015 at 11:54 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

square brackets

I would like to substitute a phrase which contains square brackets. change TO how? Thanks (2 Replies)
Discussion started by: gilead29
2 Replies

2. UNIX for Dummies Questions & Answers

Run non-root script as root with non-root environment

All, I want to run a non-root script as the root user with non-root environment variables with crontab. The non-root user would have environment variables for database access such as Oracle or Sybase. The root user does not have the Oracle or Sybase enviroment variables. I thought you could do... (2 Replies)
Discussion started by: bubba112557
2 Replies

3. Shell Programming and Scripting

Math Square Root

Hi I just stumbled on to these forums today, and I relatively new to unix. I am trying to figure out how to find the square root of a number using a shell script. I am using bash and I have searched and searched but cannot figure out square roots. Hopefully someone can point me in the right... (3 Replies)
Discussion started by: davex4285
3 Replies

4. UNIX for Dummies Questions & Answers

Area of a square

I am just starting out with bash scripting. I tried a simple script to find the area of a square and it didnt run. #!/bin/bash #script to find area of a square based on user input if then echo " Usage -$0 x " echo " where x is the dimension of the square " exit 1 n1=$1 ... (2 Replies)
Discussion started by: SnydeMz
2 Replies

5. Shell Programming and Scripting

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do... (10 Replies)
Discussion started by: worm
10 Replies

6. Shell Programming and Scripting

Delete text between square brackets and also delete those square brackets using sed or awk

Hi All, I have a text file which looks like this: computer programming systems engineering I want to get rid of these square brackets and also the text that is inside these brackets. So that my final text file looks like this: computer programming systems engineering I am using... (3 Replies)
Discussion started by: shoaibjameel123
3 Replies

7. Shell Programming and Scripting

AWK script for standard deviation / root mean square deviation

I have a file with say 50 columns, each containing a whole lot of data. Each column contains data from a separate simulation, but each simulation is related to the data in the last (REFERENCE) column $50 I need to calculate the RMS deviation for each data line, i.e. column 1 relative to... (12 Replies)
Discussion started by: chrisjorg
12 Replies

8. Solaris

Migration of system having UFS root FS with zones root to ZFS root FS

Hi All After downloading ZFS documentation from oracle site, I am able to successfully migrate UFS root FS without zones to ZFS root FS. But in case of UFS root file system with zones , I am successfully able to migrate global zone to zfs root file system but zone are still in UFS root file... (2 Replies)
Discussion started by: sb200
2 Replies

9. Shell Programming and Scripting

Mean square root error from different files

For example, I have files called A.txt and B.txt. A.txt #x yj 1 1 2 4 3 9 4 16 5 25 6 36 7 49 8 64 9 81 10 100B.txt #x ^yj 1 1 2 8 3 27 4 64 5 125 6 216 (2 Replies)
Discussion started by: Tzeronone
2 Replies

10. What is on Your Mind?

The square root code I coded on this site...

Hi all, (mainly Neo)... I keep noticing that the SQRT code I wrote recently for a POSIX shell keeps appearing, (the green colour sticks out like a sore thumb). So I decided to take a look on Google. Guess what? UNIX.COM comes first in Google's listing just from two words, see image... (2 Replies)
Discussion started by: wisecracker
2 Replies
xlsatoms(1X)															      xlsatoms(1X)

NAME
xlsatoms - list interned atoms defined on server SYNOPSIS
xlsatoms [-options...] OPTIONS
This option specifies the X server to which to connect. This option specifies a printf-style string used to list each atom <value,name> pair, printed in that order (value is an unsigned long and name is a char *). xlsatoms will supply a newline at the end of each line. The default is %ld %s. This option specifies the range of atom values to check. If low is not given, a value of 1 assumed. If high is not given, xlsatoms will stop at the first undefined atom at or above low. This option specifies the name of an atom to list. If the atom does not exist, a message will be printed on the standard error. DESCRIPTION
The xlsatoms command lists the interned atoms. By default, all atoms starting from 1 (the lowest atom value defined by the protocol) are listed until unknown atom is found. If an explicit range is given, xlsatoms will try all atoms in the range, regardless of whether or not any are undefined. ENVIRONMENT
to get the default host and display to use. SEE ALSO
X(1X), Xserver(1X), xprop(1X) AUTHOR
Jim Fulton, MIT X Consortium xlsatoms(1X)
All times are GMT -4. The time now is 11:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy