Repetitive calculations

Repetitive calculations - Estructure repeat - Messages

#1 Posted: 9/21/2023 7:14:35 PM
daniel

daniel

0 likes in 6 posts.

Group: User

Good morning, my dears, could you help me? Recently, I have been learning programming in smath. My question is whether it is possible to make a multiple input in a repetition structure, whether it is a For... That is, an example if I had several geometric figures, for example, a triangle with different measurements, let's put a number that is 100 triangles with different measurements and I would like to program with the help of a repetition structure to instruct the dimensions of each triangle to find its area

Example
For I from 1 to N Do
Input(B, H) ;
Area_(I)=0.5*B*H
End;

Is there a way to do this in smath?

mod edit: please give your threads proper titles; this help yourself to receive more, better and faster answers, and you won't be erroneously mistaken for a spammer.
#2 Posted: 9/22/2023 7:17:05 AM
Oscar Campo

Oscar Campo

124 likes in 298 posts.

Group: Moderator

Wrote

...let's put a number that is 100 triangles with different measurements and I would like to program with the help of a repetition structure to instruct the dimensions of each triangle to find its area

Example
For I from 1 to N Do
Input(B, H) ;
Area_(I)=0.5*B*H
End;

Is there a way to do this in smath?



Hi Danuko, maybe an easy way to do you need is program a simple function and define the input as a matrix:

TriangleArea.png

and here is the file: TriangleAreas.sm (5 KiB) downloaded 24 time(s).

Best,
Oscar
1 users liked this post
daniel 9/22/2023 10:47:00 AM
#3 Posted: 9/22/2023 9:28:28 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

I wonder whether you really want to input hundred of triangle specifications inside SMath.
Using matrices for input usually is a nightmare because you neither can insert rows nor can you delete ones without resorting to some programming.
You could, however, build a sort of editor with append, insert, delete functions for the data storage.

I'd prefer a multicolumn text file (e.g. csv format) and the use of the importData() function.

Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
2 users liked this post
Oscar Campo 9/22/2023 9:36:00 AM, daniel 9/22/2023 10:47:00 AM
#4 Posted: 9/22/2023 2:23:54 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

As suggested Post # 3, you can manipulate
your long rectangular triangles dimensions.
Those offered algo style collapsed.

Zillions.sm (34 KiB) downloaded 21 time(s).
#5 Posted: 9/22/2023 4:49:59 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

your long rectangular triangles dimensions.


You can even construct random or on some governing function.
All those single output values, can you pass to a music system ?
  • New Posts New Posts
  • No New Posts No New Posts