subscript combine

Use this forum to post Vensim related questions.
Post Reply
yusuke
Member
Posts: 46
Joined: Sun Apr 27, 2008 11:41 pm

subscript combine

Post by yusuke »

Hello
I want to combine subscript to new one .
I tryed Vector ELM MAP , but I cant.
Please tell me how to .

-----------------------
subscript1:
(n1-n2)
subscript3:
(K1-K6)

Array1[subscript1]=1,2,3
Array2[subscript1]=5,6,7

newVector[subscript3]=Array1[subscript1]+Array2[subscript1]
-----------------------
I want to set newVector contents like

newVector[k1]--->1
newVector[k2]--->2
newVector[k3]--->3
newVector[k4]--->5
newVector[k5]--->6
newVector[k6]--->7

-----------------------

Yusuke
Attachments
subscriptcombine.mdl
(1.52 KiB) Downloaded 174 times
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: subscript combine

Post by tomfid »

There are probably several ways to accomplish this. Not knowing anything about the meaning of the variables, it's hard to suggest the best option.

One would be:

sub1 : (n1-n3)

subK : kLower, kUpper

kLower : (k1-k3)
kUpper : (k4-k6)

Then you can write:

newvec[kLower] = array1[sub1]
newvec[kUpper] = array2[sub1]

or directly


newvec[kLower] = 1,2,3
newvec[kUpper] = 5,6,7
yusuke
Member
Posts: 46
Joined: Sun Apr 27, 2008 11:41 pm

Re: subscript combine

Post by yusuke »

Dear Tomfid

Thank you for a answer.

I try attached model using your comment.
But I can not finish it .

1)after make subscript
subK:Klower, KUpper
I can not set the subscript
kLower : (k1-k3)
kUpper : (k4-k6)
with error *KLower is already a model variable*

How can I set model?
Attachments
subscriptcombine2.mdl
(1.59 KiB) Downloaded 183 times
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: subscript combine

Post by tomfid »

Create Klower, Kupper first, then create subK.
yusuke
Member
Posts: 46
Joined: Sun Apr 27, 2008 11:41 pm

Re: subscript combine

Post by yusuke »

Dear TomFid

Thank you comment.
I can add subscript
But `model check error `show,
in
newvec[kLower] = array1[sub1]
newvec[kUpper] = array2[sub1]

"Subscript Range -sub1 appears on the right,but not left"

I attached this model.
Please give me hint about this.

Yusuke
Attachments
subscriptcombine3.mdl
(1.64 KiB) Downloaded 157 times
yusuke
Member
Posts: 46
Joined: Sun Apr 27, 2008 11:41 pm

Re: subscript combine

Post by yusuke »

Sorry my attached file have a mistake of number of data .
So I attached new one .

I still not get the solution .
Attachments
subscriptcombine4.mdl
(1.64 KiB) Downloaded 171 times
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: subscript combine

Post by tomfid »

I forgot one thing - you need to map sub1 to the k ranges:

sub1 : (n1-n3) -> klower,kupper
yusuke
Member
Posts: 46
Joined: Sun Apr 27, 2008 11:41 pm

Re: subscript combine

Post by yusuke »

Dear Tom

Thank you .
I can do it.
Post Reply