SMath Studio Forum
»
SMath Studio
»
Questions
»
extract a row from an iteration
Rank: Newbie
Groups: Registered
Joined: 17/05/2023(UTC) Posts: 9 Location: Lima
|
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
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Show your departure work, to be more helpful. Cheers ... Jean. Iterate Demo.sm (48kb) downloaded 5 time(s).
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 17/05/2023(UTC) Posts: 9 Location: Lima
|
Originally Posted by: Jean Giraud 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 (14kb) downloaded 7 time(s).
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 17/05/2023(UTC) Posts: 9 Location: Lima
|
Originally Posted by: Orlando Originally Posted by: Jean Giraud Show your departure work, to be more helpful. Cheers ... Jean. I already resolved it matrix_programming.sm (14kb) downloaded 10 time(s).
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 11/01/2018(UTC) Posts: 134 Location: Wisconsin Was thanked: 62 time(s) in 39 post(s)
|
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: Code:line(#,for(i:1,i<10,i:i+1,line(#,#,#,#,4,1)),#,3,1)
May this be of Good Help; ⚜ Kenny Lemens, P.E. ᵂᴵ |
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 17/05/2023(UTC) Posts: 9 Location: Lima
|
Originally Posted by: Kenny Lemens 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: Code: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 (17kb) downloaded 4 time(s).
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 28/08/2014(UTC) Posts: 1,359 Was thanked: 818 time(s) in 518 post(s)
|
Hola Orlando. You can use break inside the for loop. matrix_programming_for.sm (18kb) downloaded 6 time(s).Best regards. Alvaro.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 11/01/2018(UTC) Posts: 134 Location: Wisconsin Was thanked: 62 time(s) in 39 post(s)
|
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: Code: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. ᵂᴵ |
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 17/05/2023(UTC) Posts: 9 Location: Lima
|
Originally Posted by: Jean Giraud 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 (155kb) downloaded 8 time(s).
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,652 Location: Italy Was thanked: 1339 time(s) in 878 post(s)
|
Hello Orlando, Originally Posted by: Orlando 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 consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Originally Posted by: Orlando I have a problem, the power went out and now my file does not open Code the while loop from reconstruction.
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 17/05/2023(UTC) Posts: 9 Location: Lima
|
ZAPATA_AISLADA - AVANCE.sm (144kb) downloaded 6 time(s).Originally Posted by: Jean Giraud Originally Posted by: Orlando I have a problem, the power went out and now my file does not open Code the while loop from reconstruction. 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
|
|
|
|
SMath Studio Forum
»
SMath Studio
»
Questions
»
extract a row from an iteration
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.