Repetitive calculations

Repetitive calculations - Estructure repeat - Mensajes

#1 Publicado: 21/9/2023 19:14:35
daniel

daniel

1 me gusta en 6 mensajes.

Grupo: 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 Publicado: 22/9/2023 7:17:05
Oscar Campo

Oscar Campo

135 me gusta en 309 mensajes.

Grupo: 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,6 KiB) descargado 1387 vez(es).

Best,
Oscar
A 1 usuarios les gustó este mensaje
daniel 22/9/2023 10:47:00
#3 Publicado: 22/9/2023 9:28:28
Martin Kraska

Martin Kraska

1.361 me gusta en 2.275 mensajes.

Grupo: 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.

Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
A 2 usuarios les gustó este mensaje
Oscar Campo 22/9/2023 9:36:00, daniel 22/9/2023 10:47:00
#4 Publicado: 22/9/2023 14:23:54
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

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

Zillions.sm (34,43 KiB) descargado 1424 vez(es).
#5 Publicado: 22/9/2023 16:49:59
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: 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 ?
  • Nuevos mensajes
  • Sin mensajes nuevos