LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Increaseing the number of aurguments in a function

Hi all


I have written a Function to calculate a hypobolic function for a
given range of data ( in this case 5 samples). Is there a way I can
change this to accept any number of samples (I would like to accept at
least 15)? I had thought that a function using arrays might do it,
but unfortuanatly the theory behind arrays is doing my head in! here
is a copy of the function code wich I have achieved by brute force (
in summary its a funtion to add the sums of various combinations of x
and y)

Thanks for any help

Ian Mangelsdorf

Function Sw_hyp(P1, P2, p3, p4, p5, sw1, sw2, sw3, sw4, sw5, Pc_hyp)
y1 = P1
y2 = P2
y3 = p3
y4 = p4
y5 = p5
x1 = sw1
x2 = sw2
x3 = sw3
x4 = sw4
x5 = sw5



Sumx = x1 + x2 + x3 + x4 + x5
Sumy = y1 + y2 + y3 + y4 + y5
Sumx2 = x1 ^ 2 + x2 ^ 2 + x3 ^ 2 + x4 ^ 2 + x5 ^ 2
Sumy2 = y1 ^ 2 + y2 ^ 2 + y3 ^ 2 + y4 ^ 2 + y5 ^ 2


Sumxy = (x1 * y1) + (x2 * y2) + (x3 * y3) + (x4 * y4) + (x5 * y5)


'calculate x squared y's

xSy1 = x1 ^ 2 * y1
xSy2 = x2 ^ 2 * y2
xSy3 = x3 ^ 2 * y3
xSy4 = x4 ^ 2 * y4
xSy5 = x5 ^ 2 * y5

Sumx2y = xSy1 + xSy2 + xSy3 + xSy4 + xSy5

'calculate x y squared

xyS1 = y1 ^ 2 * x1
xyS2 = y2 ^ 2 * x2
xyS3 = y3 ^ 2 * x3
xyS4 = y4 ^ 2 * x4
xyS5 = y5 ^ 2 * x5

Sumxy2 = xyS1 + xyS2 + xyS3 + xyS4 + xyS5


'calculate x sq y sq

xSyS1 = y1 ^ 2 * x1 ^ 2
xSyS2 = y2 ^ 2 * x2 ^ 2
xSyS3 = y3 ^ 2 * x3 ^ 2
xSyS4 = y4 ^ 2 * x4 ^ 2
xSyS5 = y5 ^ 2 * x5 ^ 2


Sumx2y2 = xSyS1 + xSyS2 + xSyS3 + xSyS4 + xSyS5


number1 = Sumx2 * (Sumxy * Sumxy2 - Sumy * Sumx2y2) + Sumxy * (Sumx *
Sumx2y2 - Sumxy * Sumx2y) + Sumx2y * (Sumy * Sumx2y - Sumx * Sumxy2)
number2 = samples * (Sumx2y * Sumxy2 - Sumxy * Sumx2y2) + Sumx * (Sumy
* Sumx2y2 - Sumxy * Sumxy2) + Sumxy * (Sumxy ^ 2 - Sumy * Sumx2y)
number3 = samples * (Sumx2 * Sumxy2 - Sumxy * Sumx2y) + Sumx * (Sumy *
Sumx2y - Sumx * Sumxy2) + Sumxy * (Sumx * Sumxy - Sumy * Sumx2)
denomin = samples * (Sumx2y ^ 2 - Sumx2 * Sumx2y2) + Sumx * (Sumx *
Sumx2y2 - Sumxy * Sumx2y) + Sumxy * (Sumxy * Sumx2 - Sumx * Sumx2y)


a = number1 / denomin
b = number2 / denomin
C = number3 / denomin



Sw_hyp = (a - Pc_hyp) / (C * Pc_hyp - b)

End Function
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Next number function excel Excel Worksheet Functions 2 July 15th 07 05:33 PM
Excel Workbook file increaseing in size Woody Excel Discussion (Misc queries) 2 July 8th 07 09:48 AM
Excel Workbook file increaseing in size Woody Excel Discussion (Misc queries) 0 March 27th 06 06:47 PM
Increaseing Precision in polynomial trendline equations KevinW Charts and Charting in Excel 9 January 6th 06 06:41 PM
Using the autofill function but increment by certain number in function rishid Excel Worksheet Functions 1 July 14th 05 07:40 PM


All times are GMT +1. The time now is 08:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"