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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Faulty treatment of matrix indices in program?

psillem
1-Newbie

Faulty treatment of matrix indices in program?


Hi there,

I'm an experienced user of Mathcad and use Mathcad 15.0 (M010 [MC15_M010_20110622])

I encounter many bugs. Here is one.

Atached is a program concerning calculations on gears. Nothing complex, but with many variables, just following the norm. On many of the variables I need two or more [=rows(z)] values. In this case two. Use index j for that and ORIGIN=1.

In the course of the program several variables with index j are calculated. Some go wrong and show a complex answer; I corrected the values adding an extra formula row for index =1. These, in fact unnecessary lines, are marked with an A in front of the line. You can test by deleting an A marked line.

The program produces a matrix of 2 * 24. The columns are defined at the last row of the program.

Can you advise me on this one?

1 ACCEPTED SOLUTION

Accepted Solutions
AndyWesterman
4-Participant
(To:psillem)

Hi Paul,

I suspect that the line:

Capture.PNG

is the (1st) culprit.

when you loop the first time j=1 & alpha.a[2 is undefined(?)

calculating outside the program gives a complex result for this equation (a)

Splitting the program loop appears to fix the problem (b)

Hope this helps

Andy

View solution in original post

3 REPLIES 3
AndyWesterman
4-Participant
(To:psillem)

Hi Paul,

I suspect that the line:

Capture.PNG

is the (1st) culprit.

when you loop the first time j=1 & alpha.a[2 is undefined(?)

calculating outside the program gives a complex result for this equation (a)

Splitting the program loop appears to fix the problem (b)

Hope this helps

Andy

RichardJ
19-Tanzanite
(To:psillem)

It's not a bug (at least, it's not a Mathcad bug. It is a bug in your program) . The problem is in the definition of alpha.a. When j=1 d.a is a single element vector. That results in alpha.a being imaginary. On the second pass d.a is the correct two element vector, which fixes alpha.a, which fixes several variables all the way to eta.a.n, so then d.en[1, etc, calculate correctly. So Andy is correct that you need to split the loop, but the first loop only needs the definitions of k and d.a.

Version M010 does have bugs though. You should download and install M030: http://www.ptc.com/product/mathcad/free-trial/thank-you

Hi Andy and Richard,

You're right. It solves my problem. My compliments to you and thanks for your quick respons.

I'll have to be a little more careful calling bugs.

I'll try to get the M030 installed at the Engineering company.

How to proceed for your points?

Best regards,

Paul

Top Tags