output of subroutine
Posted: Thu Sep 03, 2015 9:30 am
Hello!
I have written a subroutine and have trouble getting it to work. I can run the program but I do not get any output values in my output vector interpolstat. Do I treat the output vector in the wrong way? Or is something else wrong with my program?
subroutine linintp(scalar y, scalar x, rowvector xv, rowvector yv)
for !i = 1 to @columns(xv)
if x>=xv(!i) and x<=xv(!i+1) then
y=yv(!i)+(yv(!i+1)-yv(!i))*((x-xv(!i))/(xv(!i+1)-xv(!i)))
else
next
endif
endsub
wf(wf=test, page=p1) u 10
matrix (3, 2) yieldsak
matrix (3, 2) yieldstat
matrix (3,2) loptidsak
matrix (3,2) loptidstat
rowvector (2) interpolstat
yieldsak.read(b2, s=blad1) "Y:\Documents\testlinjint.xls"
yieldstat.read(b2, s=blad2) "Y:\Documents\testlinjint.xls"
loptidsak.read(b2, s=blad3) "Y:\Documents\testlinjint.xls"
loptidstat.read(b2, s=blad4) "Y:\Documents\testlinjint.xls"
vector vloptidstat = @rowextract (loptidstat, 1)
vector vyieldstat = @rowextract (yieldstat, 1)
for !j = 1 to @columns(yieldsak)
call linintp(interpolstat(!j), loptidsak(1,!j), vloptidstat, vyieldstat)
next
Thanks in advance!
I have written a subroutine and have trouble getting it to work. I can run the program but I do not get any output values in my output vector interpolstat. Do I treat the output vector in the wrong way? Or is something else wrong with my program?
subroutine linintp(scalar y, scalar x, rowvector xv, rowvector yv)
for !i = 1 to @columns(xv)
if x>=xv(!i) and x<=xv(!i+1) then
y=yv(!i)+(yv(!i+1)-yv(!i))*((x-xv(!i))/(xv(!i+1)-xv(!i)))
else
next
endif
endsub
wf(wf=test, page=p1) u 10
matrix (3, 2) yieldsak
matrix (3, 2) yieldstat
matrix (3,2) loptidsak
matrix (3,2) loptidstat
rowvector (2) interpolstat
yieldsak.read(b2, s=blad1) "Y:\Documents\testlinjint.xls"
yieldstat.read(b2, s=blad2) "Y:\Documents\testlinjint.xls"
loptidsak.read(b2, s=blad3) "Y:\Documents\testlinjint.xls"
loptidstat.read(b2, s=blad4) "Y:\Documents\testlinjint.xls"
vector vloptidstat = @rowextract (loptidstat, 1)
vector vyieldstat = @rowextract (yieldstat, 1)
for !j = 1 to @columns(yieldsak)
call linintp(interpolstat(!j), loptidsak(1,!j), vloptidstat, vyieldstat)
next
Thanks in advance!