Conditions in vectors

Answered

Comments

3 comments

  • Avatar
    Jason

    Jackson, 

    If I understand correctly, you want to create a new vector that is essentially a copy of Vector1 with a row changed based on some criteria. 

    To accomplish this, you should set up a vector that assigns the row index with each name. Like this: Vrows = [1,2,3,4,...] so that you can then get the row value by doing row = Vrows[Alkalinity]. Once you are able to do that, please try the following:

    V2 = vector(if(row == Vrows[Alkalinity], if(V1[H] < (1.008*10**-4.5) then 0 else Alkalinity_Lookup), V1[row]))

    We make sure to stop at the index of the item we want to modify with the row == vindex() condition. This will let us single that part out so we can make assignments. The next if statement is just the condition used to know if we need to update the Alkalinity row.

    Let me know if that works for you.

    -Jason

    0
    Comment actions Permalink
  • Avatar
    Jackson White

    Hi Jason, 

    Thanks for your message! It's working now. It took me a moment to understand what the trick was with defining a data element (Vrows), to then use in the expression. I forgot to use the same row labels! 

    Thanks for your help again, 

    Jackson

    1
    Comment actions Permalink
  • Avatar
    Jason

    You are welcome, Jackson. Good luck with your model!

    -Jason

    0
    Comment actions Permalink

Please sign in to leave a comment.