Fill a matrix with scalars

For questions regarding programming in the EViews programming language.

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

olsisthebest
Posts: 18
Joined: Wed Jan 13, 2016 4:45 am

Fill a matrix with scalars

Postby olsisthebest » Fri Jan 29, 2016 4:46 am

I have 100 scalars and I want to put them into a column vector.
How can I do it with a loop?
Thank you.

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

Re: Fill a matrix with scalars

Postby EViews Gareth » Fri Jan 29, 2016 9:08 am

Code: Select all

for !i=1 to 100 v(!i) = s!i next

olsisthebest
Posts: 18
Joined: Wed Jan 13, 2016 4:45 am

Re: Fill a matrix with scalars

Postby olsisthebest » Fri Jan 29, 2016 9:39 am

Thank you, but the scalars dont have an ordinal name.
Their name do not reflect any order. Is there any alternative?

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

Re: Fill a matrix with scalars

Postby EViews Gareth » Fri Jan 29, 2016 9:43 am

Are there only those 100 scalars in the workfile, or are there other scalars too?

olsisthebest
Posts: 18
Joined: Wed Jan 13, 2016 4:45 am

Re: Fill a matrix with scalars

Postby olsisthebest » Fri Jan 29, 2016 10:06 am

There are 300 scalars.
I want to fill 3 matrices with 3 different loops.
Why do you ask? If there was only 100 scalares the procedure will be different?
Thank you, Gareth.

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

Re: Fill a matrix with scalars

Postby EViews Gareth » Fri Jan 29, 2016 10:41 am

Well if there is no naming pattern, how do you imagine EViews will know which ones to put where? The only way to do it is to manually assign if there is no logical pattern. Note you can use vector.fill to speed things up a little.

olsisthebest
Posts: 18
Joined: Wed Jan 13, 2016 4:45 am

Re: Fill a matrix with scalars

Postby olsisthebest » Fri Jan 29, 2016 10:56 am

I was thinking in put the scalars name into a string and then loop over the string.

It is possible?

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

Re: Fill a matrix with scalars

Postby EViews Gareth » Fri Jan 29, 2016 11:52 am

Sure, but easier just to use fill.

olsisthebest
Posts: 18
Joined: Wed Jan 13, 2016 4:45 am

Re: Fill a matrix with scalars

Postby olsisthebest » Mon Feb 01, 2016 8:48 am

Thank you.
It is possible to use wild cards in vector.fill argument? The scalars begin with the same letters.

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

Re: Fill a matrix with scalars

Postby EViews Gareth » Mon Feb 01, 2016 8:56 am

No.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests