How Can I Solve These Specific Issues with MathCAD Programming?

In summary, the speaker is seeking guidance on using MathCAD for their computer structural analysis class. They are having trouble with programming and outputting the correct information. They are also concerned about the length of their code and are seeking advice on consolidating it. The speaker has also posted their assignment and solution for reference.
  • #1
Fat Ryan
50
0
Mods, I wasn't sure where to put this, so please move it if its not in the correct section. Thank you.

I am in a computer structural analysis class that utilizes MathCAD as the means for all computations throughout the semester. I've never used it before, so I am having some issues. I have the book "Essential MathCAD", but there are a couple items I can't seem to find in the book (perhaps I'm looking in the wrong section?).

Anyways, the primary reason for using MathCAD in this class is to develop custom routines for doing very specific calculations. I have experience programming in VB and C++/Java; however, I'm finding it quite the PITA to program in MathCAD. One major pet pieve of mine is that I can't seem to figure out a way to add a new line in the middle of an existing routine. Every time I try clicking "add a line" in the programmer's toolbox, it does some crazy stuff and adds parenthesis and/or rearranges a bunch of stuff in the routine. No matter where the cursor is when I click "add a line", it never simply adds a line (or it adds it in the totally wrong place). Doing this in Java is beyond simple, its like adding a line in a Word document...no funny business happens. Can someone give me some guidance on this?

The next thing I'm stuck on is the output from the routine. In my particular homework assignment, I need to have an output for a particular error that includes one of the arguments in the output. It doesn't appear that this can be done with the "return" function.

Lastly, the program is supposed to exit if I have an "i" or "k" greater than the amount of rows or columns. I put a "break" function into the program, but when I execute it with the error, the program outputs "5". It doesn't matter what I change up for i & k, it still outputs "5" for some reason.

Below I have posted my assignment and my solution thus far. If you could help me out with anything, I'd appreciate it. Also, I feel like my routine is much longer than it needs to be (although it does work correctly as is), so any advice on consolidating the code is much appreciated. Thanks.

p.s.- Sorry, I posted pix because I wasn't sure how to copy the code from MathCAD...selecting and copying didn't do anything :/

2) Write a Mathcad function that exchanges the rows, columns, or rows and columns of a square symmetric matrix C. Indices i and k represent the rows or columns to be
exchanged, and the variable e is used to tell the program which operation is to be executed:

e = 1 means row exchange
e = 2 means column exchange
e = 3 means row and column exchange

The program should exit before attempting the exchange if the matrix not symmetric, if a code of e other than 1, 2, or 3 is entered, or if an indicated row or column is outside the bounds of the matrix. The message should be explicit as to what the problem is (e.g. "Error, an e code of 4 was entered"). If more than one error exists, the program should list the errors in separate lines, but in a single execution of the routine.

pic1.png

pic2.png

pic3.png
 
Physics news on Phys.org
  • #2
An error code of zero should be returned for an error free execution, and a code of 1,2,3 should be returned for an error free row, column, or row-column exchange, respectively. If an error occurs, the matrix should remain unchanged.![enter image description here][1][1]: https://i.stack.imgur.com/TvT21.png
 

FAQ: How Can I Solve These Specific Issues with MathCAD Programming?

What is MathCAD Programming?

MathCAD Programming is a mathematical programming language that allows users to solve complex mathematical problems and perform data analysis. It is often used in engineering, science, and mathematics fields.

What are the benefits of using MathCAD Programming?

MathCAD Programming has several benefits, including its ability to handle complex mathematical calculations, its user-friendly interface, and its compatibility with other programs such as Microsoft Excel. It also allows for easy documentation and sharing of calculations.

Do I need to have coding experience to use MathCAD Programming?

No, you do not need any coding experience to use MathCAD Programming. It has a visual interface that allows users to build equations and solve problems without having to write code.

How can I learn MathCAD Programming?

There are several resources available for learning MathCAD Programming, including online tutorials, user guides, and video tutorials. Many universities also offer courses on using MathCAD in their engineering and science programs.

Can MathCAD Programming be used for any type of math problem?

MathCAD Programming is designed to handle a wide range of mathematical problems, including algebra, calculus, statistics, and differential equations. However, it may not be suitable for all types of problems, particularly those that require more advanced programming languages.

Similar threads

Replies
10
Views
17K
Replies
25
Views
2K
Replies
1
Views
3K
Replies
10
Views
2K
Back
Top