This is mostly just stylistic nit-picking, but the best practice to use for the least confusion across many languages is to put spaces between operators and operands -- I feel that it makes the code more readable, and in most languages that I've used it's perfectly acceptable. In a few languages it prevents subtle errors.
So, b = 1 ./ x On Mon, 2015-04-20 at 19:09 -0400, [email protected] wrote: > Let me understand correctly. You have two conditions, namely when x>1, and > when x<=1. For x1, you want an element-by-element 1/x, not a matrix inversion > of x. > > For element-by-element division, I would use: > > b=1 ./x > > Note the space between "1" and the period "." because "1" is a number not a > variable. Look in the help section under "division". It will explain the "/" > and how to manipulate it to get what you want to achieve. > > Regards, > > > > > ___________________________ > Dr. Roger Cormier, P.Eng. > Home Tel. & Fax: 613-823-7299 > > > Le dim. 19 avr. 2015 à 11:57, fujimoto2005 a écrit : > > > I define a function with a scalar argument and use it with a matrix > > argument. > > I want to get the matrix whose entry is the functional value for each entry > > of a matrix argument. > > When the function contains no "if then" close, I get the desired result as > > the following function "f". > > However when the function contains "if then "close, the function returns the > > inverse matrix as the following function "g". > > It is because "x>1" is false as a matrix and “else part” is executed as > > inverse matrix calculation. > > I want to get the code that "if then" is applied for each entry of matrix. > > Please teach how to get such a code. > > > > **code**** > > function a=f(x) > > a=x+1 > > endfunction > > X=[1,2;3,4] > > f(X) > > > > function b=g(x) if x>1 then > > b=x+1 > > else > > b=1/x > > end > > endfunction > > X=[1,2;0.1,-0.1] > > g(X)//returns inverse(X) > > > > > > > > > > -- > > View this message in context: > > http://mailinglists.scilab.org/qustion-on-functional-argument-tp4032100.html > > Sent from the Scilab users - Mailing Lists Archives mailing list archive at > > Nabble.com. > > _______________________________________________ > > users mailing list > > [email protected] > > http://lists.scilab.org/mailman/listinfo/users > > _______________________________________________ > users mailing list > [email protected] > http://lists.scilab.org/mailman/listinfo/users > -- Tim Wescott www.wescottdesign.com Control & Communications systems, circuit & software design. Phone: 503.631.7815 Cell: 503.349.8432 _______________________________________________ users mailing list [email protected] http://lists.scilab.org/mailman/listinfo/users
