extract a row from an iteration

extract a row from an iteration - I need help writing this iteration - Messages

#1 Posted: 5/17/2023 11:23:59 AM
Orlando Suclupe Santamaria

Orlando Suclupe Santamaria

0 likes in 11 posts.

Group: User

I am learning how to use Smath Studio, I want to write an iteration where an increment of 0.5 is added to two declared variables "a" and "b" which are replaced in a formula and it gives me a final value "X" and the condition is that the iteration stops when the final value is equal to or less than a declared value "Y" to finally extract from the iteration array the row with the three values that meet this condition: [a b X]
I appreciate your help in advance, I am willing to donate
#2 Posted: 5/17/2023 1:25:27 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Show your departure work, to be more helpful.
Cheers ... Jean.

Iterate Demo.sm (47 KiB) downloaded 45 time(s).
#3 Posted: 5/17/2023 7:09:05 PM
Orlando Suclupe Santamaria

Orlando Suclupe Santamaria

0 likes in 11 posts.

Group: User

Wrote

Show your departure work, to be more helpful.
Cheers ... Jean.


This is the structure that I have been writing to iterate but I need to extract the row of interest, which in this example has to be less than or equal to sigma_adm_suelo, this row is the last

matrix_programming.sm (13 KiB) downloaded 46 time(s).

#4 Posted: 5/17/2023 7:46:44 PM
Orlando Suclupe Santamaria

Orlando Suclupe Santamaria

0 likes in 11 posts.

Group: User

Wrote

Wrote

Show your departure work, to be more helpful.
Cheers ... Jean.


I already resolved it


matrix_programming.sm (13 KiB) downloaded 51 time(s).


#5 Posted: 5/18/2023 9:27:13 AM
⚜ Kenny Lemens, P.E. ᵂᴵ

⚜ Kenny Lemens, P.E. ᵂᴵ

74 likes in 164 posts.

Group: User

Greetings,

You may want to consider the use of a for loop instead of a while statement:

Copy and Paste the following into your worksheet:
line(#,for(i:1,i<10,i:i+1,line(#,#,#,#,4,1)),#,3,1)


May this be of Good Help;
⚜ Kenny Lemens, P.E. ᵂᴵ
"No matter where you go, there you are." -Buckaroo BanzaiHotkeys: https://en.smath.com/forum/resource.ashx?a=45771&b=2
#6 Posted: 5/18/2023 10:20:07 AM
Orlando Suclupe Santamaria

Orlando Suclupe Santamaria

0 likes in 11 posts.

Group: User

Wrote

Greetings,

You may want to consider the use of a for loop instead of a while statement:

Copy and Paste the following into your worksheet:

line(#,for(i:1,i<10,i:i+1,line(#,#,#,#,4,1)),#,3,1)


May this be of Good Help;
⚜ Kenny Lemens, P.E. ᵂᴵ



The result I am looking for is that it meets the initial condition, how would I stop at the iteration that meets this condition, to be able to do it using the "for" command that you suggested and not the 10 iterations that I declare for "i"

matrix_programming_for.sm (16 KiB) downloaded 48 time(s).
#7 Posted: 5/18/2023 12:01:52 PM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1675 posts.

Group: User

Hola Orlando. You can use break inside the for loop.

matrix_programming_for.sm (17 KiB) downloaded 53 time(s).

Best regards.
Alvaro.
#8 Posted: 5/18/2023 12:05:01 PM
⚜ Kenny Lemens, P.E. ᵂᴵ

⚜ Kenny Lemens, P.E. ᵂᴵ

74 likes in 164 posts.

Group: User

Greetings,

The 'i < 10' statement would be replaced with your criteria (ie., ≤ σ.adm_suelo). Regardless, the largest issue you have is with regards to how SMath programs; you need to follow the 'rules' of setting up programming functions within a line() group, where the last item is the value returned as a result.

Copy and paste the following into your worksheet:
C.summary:+line(C:matrix(max_rows:1,3),for(i:1,({1.075*(P.CM+P.CV)}/{B.zap_0*L.zap_0}-{6*(M.CMx+M.CVx)}/{B.zap_0*L.zap_0^2}+{6*(M.CMy+M.CVy)}/{L.zap_0*B.zap_0^2}≤σ.adm_suelo),i:i+1,line(el(C,i,1):B.zap_0,el(C,i,2):L.zap_0,el(C,i,3):{1.075*(P.CM+P.CV)}/{B.zap_0*L.zap_0}-{6*(M.CMx+M.CVx)}/{B.zap_0*L.zap_0^2}+{6*(M.CMy+M.CVy)}/{L.zap_0*B.zap_0^2},B.zap_0:B.zap_0-Δ,L.zap_0:L.zap_0-Δ,5,1)),C,3,1)

The matrix produced by C.Summary should be what you are after (I simplified the equ by removing Maxima() function calls)

May this be of Good Help;
⚜ Kenny Lemens, P.E. ᵂᴵ
"No matter where you go, there you are." -Buckaroo BanzaiHotkeys: https://en.smath.com/forum/resource.ashx?a=45771&b=2
#9 Posted: 5/18/2023 12:05:09 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Maxima is not popular in the Smath Community users.
Don't even recall a single of those decoration gyzmas.

matrix_programming (1) Ignore Maxima.sm (14 KiB) downloaded 51 time(s).
#10 Posted: 5/18/2023 12:57:44 PM
Orlando Suclupe Santamaria

Orlando Suclupe Santamaria

0 likes in 11 posts.

Group: User

Wrote

Maxima is not popular in the Smath Community users.
Don't even recall a single of those decoration gyzmas.

matrix_programming (1) Ignore Maxima.sm (14 KiB) downloaded 51 time(s).



I have a problem, the power went out and now my file does not open. What can I do, does anyone know how to restore it?

ZAPATA_AISLADA.sm (154 KiB) downloaded 48 time(s).
#11 Posted: 5/18/2023 1:08:04 PM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

Hello Orlando,

Wrote

What can I do, does anyone know how to restore it?



I'm sorry but the file is not recoverable (is filled with null characters).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#12 Posted: 5/19/2023 7:53:04 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

I have a problem, the power went out and now my file does not open


Code the while loop from reconstruction.

WhileLoop.PNG

#13 Posted: 5/19/2023 12:47:36 PM
Orlando Suclupe Santamaria

Orlando Suclupe Santamaria

0 likes in 11 posts.

Group: User

ZAPATA_AISLADA - AVANCE.sm (143 KiB) downloaded 43 time(s).
Wrote

Wrote

I have a problem, the power went out and now my file does not open


Code the while loop from reconstruction.

WhileLoop.PNG



Hello, I have already made progress with a new file, I used the "for" command and after extracting the first matrix with the values that meet the condition, I made the next iteration with another formula compare the first two columns and extract the matches next to the third column that has a different result, thanks for the help to all of you, I will continue posting new concerns and I will make my donation to smath studio
  • New Posts New Posts
  • No New Posts No New Posts