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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Vector calculations

Blubblub
3-Visitor

Vector calculations

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.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

 

Calculation without errors see enclosed file.

Cheers

Terry

View solution in original post

5 REPLIES 5
LucMeekes
23-Emerald III
(To:Blubblub)

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

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.

Hi,

 

Calculation without errors see enclosed file.

Cheers

Terry

Thank you very much 🙂

The one of create the vector x in degrees.

Top Tags