Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Mathcad 2.0 won't let me define this as a variable

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-13-2013
09:42 AM

12-13-2013
09:42 AM

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

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?

Labels:

11 REPLIES 11

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-13-2013
10:11 AM

12-13-2013
10:11 AM

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

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

Alan

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-13-2013
10:12 AM

12-13-2013
10:12 AM

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

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)

Regards

Andy

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-13-2013
10:13 AM

12-13-2013
10:13 AM

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

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-13-2013
10:34 AM

12-13-2013
10:34 AM

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

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-13-2013
11:32 AM

12-13-2013
11:32 AM

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

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?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-14-2013
04:15 AM

12-14-2013
04:15 AM

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

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-14-2013
07:20 AM

12-14-2013
07:20 AM

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

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-14-2013
09:07 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-14-2013
09:26 AM

12-14-2013
09:26 AM

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

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?

Top Tags