How to use for-loop inside a function

How to use for-loop inside a function - Can't figure out the syntax - Messages

#1 Posted: 3/19/2018 7:11:17 AM
similae

similae

0 likes in 5 posts.

Group: User

I'm trying to make a function return a value from a matrix by running a small for-loop inside the function. How should I write it? Couldn't find examples how to use it.

Screenshot 2018-03-19 12.06.16.png
#2 Posted: 3/19/2018 7:49:55 AM
Brian Runagle

Brian Runagle

13 likes in 27 posts.

Group: User

Hi Mikko

The loop syntax needs tweaking, and the output variable needs to be defined. The attached file works for me.

kertoimetTest.sm (4 KiB) downloaded 118 time(s).

Hope this helps.

Brian
2 users liked this post
similae 3/19/2018 8:29:00 AM, Davide Carpi 3/19/2018 10:25:00 AM
#3 Posted: 3/19/2018 8:29:34 AM
similae

similae

0 likes in 5 posts.

Group: User

Thank you!!!


Mikko
#4 Posted: 3/19/2018 9:53:50 AM
Nicolae Olaru

Nicolae Olaru

1 likes in 115 posts.

Group: User

Greetings

I have not been able to understand the purpose for which the imagined algorithm is used. As the question arises, it is a case of express identification of a certain value in the "kertoimet" matrix. In this case in 99.99 (9 ...) of cases, the result will be an error. If so then you can avoid ambiguity using the first procedure (case identification) in the attached file. Looking at the problem in terms of practical use, in the first column of the "kertoimet" matrix there are some non-dimensional coefficients corresponding to circular x-ray surfaces with the area expressed in square millimeters. In this case, a linear interpolation of these coefficients would be useful depending on the radius of the circle, and the procedure is the one presented in the case of interpolation.

Imagination.sm (6 KiB) downloaded 54 time(s).
#5 Posted: 3/19/2018 6:16:29 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

... sorry: I understand nothing in there. Too few information.
Yes, you can best fit a circle from few points [not done in Smath]

Disk.PNG
  • New Posts New Posts
  • No New Posts No New Posts