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

Define Piecewise Function from Input Table

SOLVED

Re: Define Piecewise Function from Input Table

There is no "else" (or "otherwise" in Mathcad) in my suggestion.

The for-loop simply looks for the correct index which is then used in the last line.

Instead of using a for-loop with break it would be a cleaner approach to use a while loop.

That means following the rule  "Use a for-loop only if the number of iterations is known", which I had ignored in favor of comfort ;-)

I am not sure but I also think that there is no system variable "Origin" in SMath and vector indices always start with 1 which the routine would have to consider.

Re: Define Piecewise Function from Input Table

It was very long ago that I test drived SMath so I downloaded and installed it and gave it a try.  Feels a bit uncomfortable at first and I was missing a comprehensive help. Had to use a search machine to find help for various topics. Especially demanding was to find out how to add a new line in a program without adding a new vertical line, too. Found no keyboard short but just a way to do it with the mouse :-(

I found no equivalent to Mathcad's "ORIGIN", so I assume indexing starts with 1 and you can't change that.

Also I found no way to get rid of the "else" branch, which is not needed in our example. You may put anything there, a zero would be just fine. I decided for "continue" as in our case that's exactly what happens.

I also include the "cleaner" version which uses a "while" loop.

B.png

 

BTW, I remember there was an installer package which also included the most important add-ons and settings, which made for a good start. At first glance I was not able to find anything like that now and installed the pure program alone (and missed a lot, of course).

While I am aware that this is not the SMath forum - two questions anyway:

Does anybody know if there are that kind of "all-inclusive" installation packages still available?

I also found that many menus are unusable because I use a notebook with a 4K display. Does anybody know if there is a fix for this. The pic below show what I am experiencing and talking about:

B2.png

EDIT: I was not able to attach the SMath file directly as I experienced the "The contents of the attachment doesn't match its file type" error message. We know this problem very well as it took endless until this problem had been finally resolved for Mathcad files. So it was needed  to zip the file.

 

Re: Define Piecewise Function from Input Table

OK, the lookup-functions that were presented here have no error check anyway but I thought that the "while" version should at least be as good as the "for" one, So I guess its a good idea to prevent the index going up to high:

B.png