How do you evaluate a function over a range of more than one variable? Rate-Time Decline Curve Analysis
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
txvmi07
am 11 Jun. 2014
Kommentiert: José-Luis
am 11 Jun. 2014
After a lot of trial and error I am still unable to generate the output I desire in what I believe is the correct and most efficient method in Matlab. I am using Matlab as an alternative to Excel in order to more efficiently calculate and display the data, so I'm hoping to be able to solve this issue with your help. Thanks in advance!
Quite simply, I am trying to calculate the value of "q" given an initial rate "qi", a constant "b", and a decline rate "di" at time t. I have been successful at calculating the function and solving for q over a range of "t" values. by setting t = 0:n. (see formula and code below)
%Decline curve with b-factor comparison
% qi = IP rate
% di = initial decline rate
% b = B-factor
% t = time period
qi=1000; b = 1; di=.012; t=0:14600;
function q = hbcurve(qi,b,di,t) %define function
q = qi*(1+b*di*t).^(-1/b); %function forumula
My Problem: I am having difficulty in being able to evaluate the function over a range of t values as mentioned above while simultaneously evaluating the function over b = 1:0.1:2. I've been able to calculate these values but only by manual iteration of the functions. I've scoured this site, manuals, blogs, etc, and tried for loops and pre-allocation to no avail.
My Goal: Evaluate the function over a range of the variable "t" and "b" and output this data to a matrix with dimensions are as long and wide as the "t" and "b" variables. I am trying to avoid achieving my goal with code such as that below.
b1 = hyperdecline(qi,1,di,t); b1cum = cumsum(b1);
b11 = hyperdecline(qi,1.1,di,t); b11cum = cumsum(b11);
b12 = hyperdecline(qi,1.2,di,t); b12cum = cumsum(b12);
b13 = hyperdecline(qi,1.3,di,t); b13cum = cumsum(b13);
b14 = hyperdecline(qi,1.4,di,t); b14cum = cumsum(b14);
b15 = hyperdecline(qi,1.5,di,t); b15cum = cumsum(b15);
b16 = hyperdecline(qi,1.6,di,t); b16cum = cumsum(b16);
b17 = hyperdecline(qi,1.7,di,t); b17cum = cumsum(b17);
b18 = hyperdecline(qi,1.8,di,t); b18cum = cumsum(b18);
b19 = hyperdecline(qi,1.9,di,t); b19cum = cumsum(b19);
b2 = hyperdecline(qi,2,di,t); b2cum = cumsum(b2);
0 Kommentare
Akzeptierte Antwort
José-Luis
am 11 Jun. 2014
Bearbeitet: José-Luis
am 11 Jun. 2014
t=0:14600;
b = 1:0.1:2;
[T B] = ndgrid(t,b);
Now you can evaluate your function for all values of T and B. You can either loop through all values (that would sort of defeat the point of using ndgrid() though ), or you could rewrite hbcurve() so it accepts array inputs:
q = qi*(1+B.*di.*T).^(-1./B);
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!