Repetitive calculations

Repetitive calculations - Estructure repeat - Сообщения

#1 Опубликовано: 21.09.2023 19:14:35
daniel

daniel

0 сообщений из 6 понравились пользователям.

Группа: 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 Опубликовано: 22.09.2023 07:17:05
Oscar Campo

Oscar Campo

124 сообщений из 298 понравились пользователям.

Группа: 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 КиБ) скачан 24 раз(а).

Best,
Oscar
1 пользователям понравился этот пост
daniel 22.09.2023 10:47:00
#3 Опубликовано: 22.09.2023 09:28:28
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: 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 пользователям понравился этот пост
Oscar Campo 22.09.2023 09:36:00, daniel 22.09.2023 10:47:00
#4 Опубликовано: 22.09.2023 14:23:54
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

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

Zillions.sm (34 КиБ) скачан 22 раз(а).
#5 Опубликовано: 22.09.2023 16:49:59
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: 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 ?
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений