Skip to main content
1-Visitor
December 13, 2013
Question

Mathcad 2.0 won't let me define this as a variable

  • December 13, 2013
  • 6 replies
  • 6822 views

See the attached image;

mathcadproblem.PNG

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?

6 replies

19-Tanzanite
December 13, 2013

You need to look up the difference between a range variable and a vector.

vectors.PNG

Alan

12-Amethyst
December 13, 2013

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:

Capture.PNG

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)

Regards

Andy

25-Diamond I
December 13, 2013

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

  • indexing and accessing vectors and matrices
  • as the independent variable in plotting a function
  • in programs at for-loops

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.

25-Diamond I
December 13, 2013

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.

13.12.png

1-Visitor
December 13, 2013

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?

reply.PNG

19-Tanzanite
December 14, 2013

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.

Alan

24-Ruby IV
December 14, 2013

adam miller wrote:

See the attached image;

mathcadproblem.PNG

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?

In Prime 3 with a Table:

ab.png

25-Diamond I
December 14, 2013

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?

24-Ruby IV
December 14, 2013

Werner Exinger wrote:

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?

Pardon, I do not quit understand the topic.