Page 1 of 1

subscript combine

Posted: Thu Jul 23, 2020 7:08 pm
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

Re: subscript combine

Posted: Thu Jul 23, 2020 7:53 pm
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

Re: subscript combine

Posted: Fri Jul 24, 2020 12:06 am
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?

Re: subscript combine

Posted: Fri Jul 24, 2020 1:44 am
by tomfid
Create Klower, Kupper first, then create subK.

Re: subscript combine

Posted: Fri Jul 24, 2020 8:09 am
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

Re: subscript combine

Posted: Sat Jul 25, 2020 1:58 am
by yusuke
Sorry my attached file have a mistake of number of data .
So I attached new one .

I still not get the solution .

Re: subscript combine

Posted: Mon Jul 27, 2020 3:58 am
by tomfid
I forgot one thing - you need to map sub1 to the k ranges:

sub1 : (n1-n3) -> klower,kupper

Re: subscript combine

Posted: Tue Jul 28, 2020 1:09 am
by yusuke
Dear Tom

Thank you .
I can do it.