How to use for-loop inside a function

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

#1 已发布: 2018/3/19 07:11:17
similae

similae

0个赞,共5个帖子。

组: 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 已发布: 2018/3/19 07:49:55
Brian Runagle

Brian Runagle

13个赞,共27个帖子。

组: 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.72 KiB)已下载 1357 次。

Hope this helps.

Brian
2位用户喜欢此帖子
similae 2018/3/19 08:29:00, Davide Carpi 2018/3/19 10:25:00
#3 已发布: 2018/3/19 08:29:34
similae

similae

0个赞,共5个帖子。

组: User

Thank you!!!


Mikko
#4 已发布: 2018/3/19 09:53:50
Nicolae Olaru

Nicolae Olaru

1个赞,共115个帖子。

组: 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.22 KiB)已下载 1256 次。
#5 已发布: 2018/3/19 18:16:29
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: 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
  • 有新帖
  • 无新帖