cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

SOLVED
Participant

array index invalid

Hi,

I'm trying to replicate a template that evaluates the shear and moment of a simple beam. The problem is that to W array, I've got the message that n is invalid. The index should be an integer that it is n=3, no less than origin that it is because i have set up origin=1 and no greater than the last element which i don't know if is true. Any idea how can I fix it?

Thanks

Thank you all for taking the time. It was the origin :1 that was not written as it should so no all sorted.

Thank you very much anyway!!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: array index invalid

Hi Luc,

thanks for the reply. I have set the origin to 1 at the first row. The thing is that n=3 and not 2. That will give me the right result. As I've mentioned I'm just replicating a template that makes sense so at the end VL- should be a 3x1 vector and changing this value doesn't give me the right result. I'm attaching the template to see the results that I should have. I understand that it is 3>2 that's the issue but how could I write it differently to return the values as per the template?

Thanks,

6 REPLIES 6

Re: array index invalid

Please attach the Prime worksheet. (You should ALWAYS do that.)

Apart from that:

works, because the length of p (=2) is less than that of a (=3)

throws an error because the length of w (=3) is NOT less than that of a (=3). Therefor the if tries to execute the 'else' statement, accessing p.n. with n=3. You probably missed that (by default) ORIGIN=0, which means that arrays are indexed starting at 0, not at 1, p.3 doesn't exist, the last element of p is p.2.

That makes W undefined.

set                  n:=last(a)

Then n will become 2 and these errors disappear.

Leaves you with one more error at the end (actually 2, read on...). You have defined an M.L at the top, in the end you use M[L. Those are different. The first is a literal subscript (the result of typing M[CTL _]L ), the other is an array subscript (the result of typing M[L ) which requires the vector M to exist.... it doesn't. The error for M[R isn't flagged yet, Prime flags only one error per expression...

Success!

Luc

Hi,

Cheers,

Re: array index invalid

Hi Luc,

thanks for the reply. I have set the origin to 1 at the first row. The thing is that n=3 and not 2. That will give me the right result. As I've mentioned I'm just replicating a template that makes sense so at the end VL- should be a 3x1 vector and changing this value doesn't give me the right result. I'm attaching the template to see the results that I should have. I understand that it is 3>2 that's the issue but how could I write it differently to return the values as per the template?

Thanks,

Re: array index invalid

It looks like you've defined "w" as a matrix and not a vector (array). Prime is looking for a 2-dimension assignment/callout.

Re: array index invalid

No, w is defined as a vector, due to the transpose operator.

Luc

Re: array index invalid

Ah yes, noted...my quick trial left out the transpose operator...

Announcements
Check out the latest