output of subroutine

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

sakerstallda
Posts: 7
Joined: Thu Aug 27, 2015 5:17 am

output of subroutine

Postby sakerstallda » 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!

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: output of subroutine

Postby EViews Gareth » Thu Sep 03, 2015 9:57 am

Nothing strikes me as being wrong. Are you sure the if condition is actually ever met?


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest