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
- :
- Re: Vector calculations

Options

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

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

Showing results for

Highlighted

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

06-20-2020
12:40 PM

06-20-2020
12:40 PM

I'm seminew to Mathcad, and I know my question is fairly basic, however, I was not able to find the answer either through google nor through clicking around in the PTC online manual.

This is my first attempt at making vectorized calculations, however, I keep failing doing them. The program simply shuts me down by giving me the error message that I must use a matrix or a scalar.

The equation I try to do is fairly straightforward:

1) Define a vector with a range x:=1..5

2) Implement an equation H*sin(x/L*pi)

everything works swell, until I try to save that value, simply by putting something in front of it.

Let's say: y:=H*sin(x/L*pi)

At this point it suddenly decides to tell me no, it must be a scalar, I'm not allowed to do this.

What's the reason? How do I get around it?

Second question: Is it possible to have a simple index system such as x(1), rather than x_1? I haven't figured the indexing system at all, btw. Everytime I try to call any of the vector values, I fail. I can work on the vector, as long as I don't try to save it as another variable, and I cannot call any values from it.

Best regards, thanks in advance for some help, and sorry for me asking such basic questions. Yet again, I did an honest attempt to find the answer elsewhere so to not spam and waste your time.

EDIT: I just wanted to thank all of you who helped me out. As you all stated correctly, range isn't the same as a vector. I didn't know that, especially since it becomes one once you press the "=" sign, so it's displayed as one.

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

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

06-20-2020
05:39 PM

06-20-2020
05:39 PM

5 REPLIES 5

Highlighted
##

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

06-20-2020
03:13 PM

06-20-2020
03:13 PM

Re: Vector calculations

Please attach your worksheet. That will help tremendously.

Oh, defining x:=1...5 does NOT define x as an array or vector. It defines x as a range. That works well for plotting, but you cannot index into a range.

Success!

Luc

Highlighted
##

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

06-20-2020
04:10 PM

06-20-2020
04:10 PM

Re: Vector calculations

What you define with x:=1..5 is NOT A VECTOR, its a range. Thats the reason for the error message you get.

A range is kind of an implicit loop and should only be used in three cases:

1) to index a vector or matrix

2) in a program when you use a for-loop

3) to control the abscissa values of a 2D-plot

Otherwise you have to define a vector!

There is an undocumented trick to turn a range into a vector. If you follow the range definition by a numerical inline evaluation you get a vector -> x:=1..5=

Otherwise you may define:

i:=0..4

x[i:=i+1

I am assuming you are using the default value for ORIGIN, which is 0.

According to x(1) versus x[1: This depends. If you use real Mathcad, you have to use the vector index (which you get by typing [). If you have to use Prime, you may also type x(1) instead of x[1 if x is a vector to access the element with the number 1 (usually the second entry if ORIGIN=0). Personally I dislike this syntax as its easily confused with a function call.

Highlighted

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

06-20-2020
05:39 PM

06-20-2020
05:39 PM

Highlighted
##

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

06-21-2020
04:18 AM

06-21-2020
04:18 AM

Re: Vector calculations

Thank you very much 🙂

Highlighted
##

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

06-22-2020
08:35 AM

06-22-2020
08:35 AM

Re: Vector calculations

The one of create the vector x in degrees.