See the attached image;
Why can it process a+3 and give me a perfectly good answer, but go to define said answer as its own variable B and it won't let me??? How do I do this?
I don't know if it is intentional or not but you can make prime accept this by adding the range variable as a subscript to the b in the assignment:
NB: it only works for integer ranges.
I have also changed the 'ORIGIN' to 1 to match your range; If you don't do this the b will contain 0,4,5,6,7.
But it is a global assignment so it will affect every array defined.
If this is a problem & ORIGIN=0 is required, then you need to change b[a to b[a-1 (in this case)
Its important to learn the difference between ranges and vectors!
a is a range variable, not a vector even if the evaluation of a or a+3 might look like a vector (which was not a good choice by Mathcad anyway).
A range variable may be seen as kind of an implicit for-loop.
Range variables should be used in a limited way only
Create a as a vector and your assignment will work.
The problem exist since the beginnings of Mathcad and always was a pitfall for new users. I attach a pdf of two files by Stuart Bruff about Vectors vs. Ranges.
There is a way to quickly turn a range variable into a vector by adding an inline evaluation. I am not sure if thats intentional and as far as I am aware of this trick is undocumented. So I guess we should not rely our worksheets on it too heavily.
I was able to get this to work both with the subscript based matrix method, as well as by putting in the =sign.
The problem I am now finding is for what I am really trying to do, I want to use the values y1, and y2 in subscripts. Doing this kind of makes it hard to do the subscript based matrix A Westerman showed, On the other hand, having to put the 2nd equals sign in after the definition works but leads to a very inefficient use of space. Any ideas?
Subscripts must have integer values, so you will need to create, say, i:=0..100 and then create y1[i:= i/100 and y2:=y1-alpha. I guess you then want another variable to depend on these, but you will have to create that as a function, say fn(y1,y2), or as a double subscripted variable fn[i,j where j also runs from 0 to 100.
The problem I am now finding is for what I am really trying to do, I want to use the values y1, and y2 in subscripts.
As Alan already wrote - you can't, as subscripts must be integers. Probably I shouldn't have suggested the method using inline evaluation, but didn't recommend it anyway.
The usual way for creating a vector "by hand" is using an auxiliary range variable. You may also use a programming approach, but this may be considered too cumbersome:
You may use the inline evaluation trick, its quick and dirty but not documented and so not recommended. The displayed vector can be made smaller to save space
You may also consider using a user written auxiliary function, especially if you have more vectors to create in your sheet or you are too lazy to calculate how "long" your range variable has to be ;-)
I attach the sheet in Prime2 format.
EDIT: There was an error in the last routine which is now fixed
Valery Ochkov wrote:
In Prime 3 with a Table:
A bit too cumbersome for the 101-element vector Adam needs, don't you think so, too?