Repetitive calculations

Repetitive calculations - Estructure repeat - Messaggi

#1 Pubblicato: 21/09/2023 19:14:35
daniel

daniel

1 apprezzamenti in 6 post.

Gruppo: 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 Pubblicato: 22/09/2023 07:17:05
Oscar Campo

Oscar Campo

135 apprezzamenti in 309 post.

Gruppo: 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) scaricato 1389 volta(e).

Best,
Oscar
1 utenti hanno apprezzato questo post
daniel 22/09/2023 10:47:00
#3 Pubblicato: 22/09/2023 09:28:28
Martin Kraska

Martin Kraska

1.361 apprezzamenti in 2.275 post.

Gruppo: 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
2 utenti hanno apprezzato questo post
Oscar Campo 22/09/2023 09:36:00, daniel 22/09/2023 10:47:00
#4 Pubblicato: 22/09/2023 14:23:54
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: User

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

Zillions.sm (34,43 KiB) scaricato 1426 volta(e).
#5 Pubblicato: 22/09/2023 16:49:59
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: 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 ?
  • Nuovi post
  • Nessun nuovo post