For loop error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
For loop error
I'm new to MathCAD(using MathCAD15). I'm trying to write a program that iterates through a set of data to locate the falling edge of a trip signal. The data set I am working with has thousands of lines where the voltage drops from arround 2.5v to around zero at the time a machine trips offline. I wrote a silplified program with only 10 datapoints as a baby step tward my goal. I am getting an error that doesnt make sense to me. "This value must be a Matrix of scalar elements"
See the attached program, any help is appriciated.
Solved! Go to Solution.
- Labels:
-
Statistics_Analysis
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
It would be easier if you attach a worksheet. It's hard to debug an image.
Probably, if you right click on the absolute value operator, |, it will be set to "square matrix determinant". Select "absolute value" instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
1. Instead of n0,0 and ni,0 just use n0 and ni, because n is just a vector.
2. Better to upload a worksheet, not just an image.
Alan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
It would be easier if you attach a worksheet. It's hard to debug an image.
Probably, if you right click on the absolute value operator, |, it will be set to "square matrix determinant". Select "absolute value" instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks guys. I had been fighting with that for about an hour. You answered my question in <5min.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Instead of for and break you could use the while-statement:
The result of my routine differes from yours when the vector consists of 1's only. Not sure what result you expect in that case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Another routine using a For Loop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
A good one!
And while we are at that "make it shorter" contest, here a a very short and completely different approach:
It throws an error if the vector consist of all 1's which can easily be coped with an "onerror" statement.
BTW, I feel that a for-loop should not be terminated prematurely, whether using break or using return. But I admit that thats a very puristic point of view. And I am very often missing a "do-while" or "Repeat-Until" construction.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Werner Exinger wrote:
A good one!
And while we are at that "make it shorter" contest, here a a very short and completely different approach:
I like it
Werner Exinger wrote:
BTW, I feel that a for-loop should not be terminated prematurely, whether using break or using return.
To be honest I do not usually construct for-loops that way, but the eager to reduce the program lines got to me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
To be honest I do not usually construct for-loops that way, but the eager to reduce the program lines got to me.
I understand what you mean ;-). I won't recommend my last one as well as for bad readability.
