Sponsored Content
Full Discussion: A strange formula
Top Forums Shell Programming and Scripting A strange formula Post 302869577 by ipatah on Wednesday 30th of October 2013 03:01:10 PM
Old 10-30-2013
Dear Askhay and Masters,


I did these for this input..
Code:
  DEPTH     DTCO     DTSM     GR     NPHI     VpperVs     PERM     PHIT     RHOB     VPVS     VSH
642.9987    -999.25    -999.25    79.124    0.643    -999.25    -999.25    -999.25    1.69    -999.25    -999.25
643.4987    -999.25    -999.25    75.862    0.584    -999.25    -999.25    -999.25    1.707    -999.25    -999.25
643.9987    -999.25    -999.25    74.2    0.593    -999.25    -999.25    -999.25    1.728    -999.25    -999.25
644.4987    -999.25    -999.25    77.366    0.571    -999.25    -999.25    -999.25    1.736    -999.25    -999.25
644.9987    -999.25    -999.25    82.955    0.525    -999.25    -999.25    -999.25    1.731    -999.25    -999.25
645.4987    -999.25    -999.25    84.246    0.595    -999.25    -999.25    -999.25    1.724    -999.25    -999.25
645.9987    -999.25    -999.25    80.992    0.607    -999.25    -999.25    -999.25    1.723    -999.25    -999.25
646.4987    -999.25    -999.25    76.48    0.555    -999.25    -999.25    -999.25    1.722    -999.25    -999.25
646.9987    -999.25    -999.25    77.335    0.552    -999.25    -999.25    -999.25    1.72    -999.25    -999.25

I run
Code:
awk '{print $1"   "$2"   "$3"   "$9"   "$6}' input_file > inp; awk '{print $6}' input_file > one_colom;
./script1.txt < inp > out1; paste out1 one_colom> out1a
./script3.txt < out1a > out2; 
grep -v "p "out2 | grep -v "q " | grep -v "r " > out3;
grep Angle out3 > out4;
grep -v Angle out3 > out5;  grep Angle out3 > out5raw;
awk 'BEGIN {FS=OFS=" "} { print; for (i=2; i<=NF; ++i) sum[i] += $i; j=NF } END { printf "%s%s", "------------------", "\nAvg"; for (i=2; i <= j; ++i) printf "%s%s", OFS, sum[i]/NR; printf "\n"; }' out5 > out6;
cat out5raw out6 > out7;

after these command, i got average value, but VpperVs value will be place at the end column. I still find any idea for next step.. kindly need your helps

where script1.txt
Code:
awk  '
  NR>2{
            ++n
            vp+=$2; vs+=$3; rho+=$4;Vp_Vs+=($2/$3)^2
            for(i=1;i<=6;i++)A[n,i]=$i
      }
END{
        vpo  = vp/n
        vs0  = vs/n
        rho0 = rho/n
        k    = Vp_Vs/n
 
 printf "Angle" OFS "p" OFS "q" OFS "r" OFS
        for(x=1;x<=n;x++)printf A[x,1] OFS;printf "\n"
for(j=-90;j<=90;j++){
                             p=cos(j)+sin(j)
                             q=-8*k*sin(j)
                             r=cos(j)-(4*k*sin(j))
                             printf j OFS p OFS q OFS r OFS 
           for(i=1;i<=n;i++){
                                   EEI=vpo*rho0*((A[i,2]/vpo)^p) * ((A[i,3]/vs0)^q) * ((A[i,4]/rho0)^r)
                                   printf EEI OFS 
                            }
                                  printf "\n"
                    }
   }' OFS="\t" CONVFMT="%5.3f" OFMT="%.2g"

where script3.txt
Code:
awk      '{
          if (max_nf < NF)
               max_nf = NF
          max_nr = NR
          for (x = 1; x <= NF; x++)
               vector[x, NR] = $x
     }
     END {
          for (x = 1; x <= max_nf; x++) {
               for (y = 1; y <= max_nr; y++)
                    printf("%s ", vector[x, y])
               printf("\n")
          }
     }'

Thanks and Regards,
Ipatah
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Quadratic Formula Program

I have a question about the program I am making. I finished it, compiled it, and there were no errors. Now when I run it, the comand prompt comes up and there are just 1's and 0's that keep looping over and over again. The program is listed before. If anyone has any suggestions I would greatly... (2 Replies)
Discussion started by: zeek
2 Replies

2. Shell Programming and Scripting

Help with formula in a script

I need some help. I been doing system admin for the last several years and gotten very rusty on scripting. I need to write a script that will take a log entry and do math using two columns of data to create a new column. I am taking the column(#2) that contains the time and the column(#5) that... (3 Replies)
Discussion started by: scottzx7rr
3 Replies

3. Solaris

formula to get the swap space on a machine

Hello there are different opinions on how to get the swap space on Solaris. some say: swap -s and the space= used + available others say swap -l (donno how they get the swap size) other say 'top' command others say using format command (in print sub-command) Could you please advise on... (1 Reply)
Discussion started by: melanie_pfefer
1 Replies

4. UNIX for Dummies Questions & Answers

Formula help

The formula below will calculate a distance in miles between 2 points in excel. Can some put it to work in unix? Lat = 43.335 Lon1 = -70.9884 Lat2 = 43.4829 Lon2 = -71.246 distance... (8 Replies)
Discussion started by: bobo
8 Replies

5. Shell Programming and Scripting

how to create script for this formula?

Hello Unix gurus, Can anyone tell me the most efficient way to create script for the formula? Formula: Ans = 1 - ((Buffer pool data physical reads + Buffer pool xda physical reads + Buffer pool index physical reads + Buffer pool temporary data physical reads + Buffer pool temporary xda... (6 Replies)
Discussion started by: Rahulpict
6 Replies

6. Shell Programming and Scripting

Formula to get combination… sum

Formula to get combination Lats say, I have 5 values ID Price 1 5 2 10 3 30 4 5 Resule with Possible combinations will be ID Price 1 5 2 10 3 30 4 5 1+1 10 1+2 15 1+3 35 1+4 10 (1 Reply)
Discussion started by: Amit.Sagpariya
1 Replies

7. Shell Programming and Scripting

Convert Formula to Value

I'm new to Perl, but I need to use it to write into an excel spreadsheet. I want to copy the values of certain cells into a new sheet in the workbook. I'm unsure of how to do this because I don't know how to copy values instead of formulas. Note: by formula I mean '=SUM(A1,A2)' and by value I... (0 Replies)
Discussion started by: AgentSmith88
0 Replies

8. Shell Programming and Scripting

formula missing in excel after using perl

Dear all, I got a template excel file which contains several worksheets. Each worksheet contains some formulas in the cells. I am using the perl script to read a CSV file and then put the data of CSV into template excel file(first worksheet) and then save it as new file name using ... (0 Replies)
Discussion started by: eldonlck
0 Replies

9. Shell Programming and Scripting

Formula missing in excel after using perl

Hi all, I use "Spreadsheet::ParseExcel::SaveParser" to - read a existing excel file with : $Parser = Spreadsheet::ParseExcel::SaveParser->new(); $HeaderFile = $Parser->Parse("XLS_FILE_ACCESS"); - modify some values in somes cell with : $worksheet->AddCell($row_target,$col_max,... (3 Replies)
Discussion started by: Yom
3 Replies

10. Solaris

Formula calculate scan rate

Hi There, Just curious here... If there formula to calculate scan rate on solaris? Thanks Edy (3 Replies)
Discussion started by: edydsuranta
3 Replies
All times are GMT -4. The time now is 01:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy