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: Inscrutable Error with Simple Program

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

12-01-2011
04:24 PM

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

12-01-2011
04:24 PM

Inscrutable Error with Simple Program

My goal was to determine the size of a single dimension index based on the

contents of the first column [row] of a matrix. For instance if I have Q=(1,0,2) I want

an index N=2, for two non-0 elements for Q1 and Q3. Q can be any size and any

number of 0 elements can exist. I attach a simple replica of the program I used

to calculate this index, using the "for" and "if" functions. It seems simple so I am

feeling pretty stupid right now. Can you see anything wrong with the attached

program? It was developed in MathCAD 2001i [V8].

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

12-01-2011
06:48 PM

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

12-01-2011
06:48 PM

I can't open your program, my computer doesn't recognise "zipx"

Does the attached help?

16 REPLIES 16

12-01-2011
06:48 PM

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

12-01-2011
06:48 PM

I can't open your program, my computer doesn't recognise "zipx"

Does the attached help?

12-01-2011
08:46 PM

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

12-01-2011
08:46 PM

Fred

The program and set up you sent works as I would have intended mine to work.

There is not much different in what I did than what you show. The only real differences

were that I have a one dimensional matrix [simpler] and I did not express the LHS

of the program as a function or the rows(A). Instead I simply embedded this number

in the for statement. My lines are generally as follows.

N= i set to 0

for k E 1 .... cols(Q)

i=i+1 if Q(k) <=> 0 |Q(k) is the column k of Q

[i=i otherwise, or no statement same effect]

i

This would give me N=3, total columns of Q, instead of 2, in my example, with non-zero

elements.

I will try your suggestion and I am sure it will cure my issue.

Thank you,

Paul

12-02-2011
02:38 AM

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

12-02-2011
02:38 AM

To me Fred's solution looks a little different to what you were after.

Please re-upload the worksheet.

Mike

12-02-2011
03:24 AM

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

12-02-2011
03:24 AM

I opened this file (ZIPX) using WinZip 15.5.

**P.S. **Unfortunately, at this moment I do not have access to Mathcad.

12-02-2011
03:28 AM

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

12-02-2011
03:28 AM

Cheers.

Mike

12-02-2011
12:57 PM

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

12-02-2011
12:57 PM

Mike

I have tried to re-upload a document to the current discussion

but being a relatively new participant I could not find a way to

do this. Ultimately I uploaded the document to the programming

group but it doesn't appear in the discussion thread. My problem

has been solved. It was a silly oversight on my part. In my single

dimension array Q=(1 0 2) say, my program was written to check

Q<k> = 0. But Q<k> only returns the array of that one cell, not its

value. Hence I needed to at least add indices Q<k>[1,1 to the program.

Better though is simply to use Q[1,k = 0 as the test. This works.

Thank you,

Paul

12-02-2011
12:59 PM

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

12-02-2011
12:59 PM

Hi Paul,

I have just commented on the document you posted. If you click on the 'use advanced editor' link in the top right hand corner you can then upload worksheet and attached files.

Mike

12-02-2011
01:04 PM

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

12-02-2011
01:04 PM

I forgot to add - While it is your prerogative which version to choose to adopt. Fred's example doesn't indicate the total amount of zero's in a Matrix, which is what you were after isn't it?

Mike

12-02-2011
07:27 AM

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

12-02-2011
07:27 AM

Andy.

If you change Q<k> to Q[1,k address the kth element of the first row rather than the whole kth column your program works.

Thanks, Vladimir, for unpacking it!

12-03-2011
07:30 AM

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

12-03-2011
07:30 AM

Fred Kohlhepp wrote:

...Thanks, Vladimir, for unpacking it!

No problem.

12-02-2011
04:12 AM

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

12-02-2011
04:12 AM

The problem appears to be that k<0> is returning an array & that isn't equal to a scalar.

There are a couple of alternate methods to achieve the function attached

Best regards

Andy

12-02-2011
04:15 AM

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

12-02-2011
04:15 AM

Another method?

Mike

12-02-2011
07:29 AM

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

12-02-2011
11:35 AM

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

12-02-2011
11:35 AM

Mike,

That is a clever function. Not sure what the expression in the upper limit of the first sum is to accomplish?

in the original file, Q<=>0, doesn't exclude real number. But I don't think that syntex is recoginized anyway.

12-02-2011
12:54 PM

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

12-02-2011
12:54 PM

Mike,

That is a clever function. Not sure what the expression in the upper limit of the first sum is to accomplish?

Good spot Wayne.

It wasn't meant to accomplish anything. It was a typo

Mike

12-02-2011
01:51 PM

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

12-02-2011
01:51 PM

Andy: You are absolutely right. I needed the scalar not the array. Thanks Paul