cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

I have a problem with Matrixs and if/for loop

Sarp22
1-Newbie

I have a problem with Matrixs and if/for loop

I tried to create a program that can calculate capacity of a concrete column. However, I had a problem with matrixs and if/for loop. Even my input is a matrix; my output of for/if loop is a number. I could not solve that. Project is attached. I would be glad if anybody can help me and solve this. 

1 ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:Sarp22)

Maybe this helps:

The result of a program is the result of the last executed statement before it ends.

If you run through a vector or matrix element by element and your last statement assigns the last element of your vector or matrix, than that (last element value) is the result of your program.

Note that in the programming palet there is a 'result' item which requires a parameter. You should use that at the end of your program, after any (nested) for loop and supply the (full) name of the result vector or matrix as the parameter.

Note that the 'result' item causes your program to stop. If you use it anywhere in a program, that's where it stops.

 

Success!
Luc

View solution in original post

6 REPLIES 6
LucMeekes
23-Emerald III
(To:Sarp22)

Maybe this helps:

The result of a program is the result of the last executed statement before it ends.

If you run through a vector or matrix element by element and your last statement assigns the last element of your vector or matrix, than that (last element value) is the result of your program.

Note that in the programming palet there is a 'result' item which requires a parameter. You should use that at the end of your program, after any (nested) for loop and supply the (full) name of the result vector or matrix as the parameter.

Note that the 'result' item causes your program to stop. If you use it anywhere in a program, that's where it stops.

 

Success!
Luc

Hello Luc,

Thanks for your answer. However, I did not use any "result" in the loop. I tried to use two "for" loops and one "if" to compare values of a matrix with two limits and get a new matrix. But it gives only the last parameter.  

LucMeekes
23-Emerald III
(To:Sarp22)

That's what I explained. The progam results in the last executed statement. That is e3j.

You HAVE to use 'result'.

 

Success!
Luc

LucMeekes
23-Emerald III
(To:LucMeekes)

Look at the difference here:LM_20190725_Program.png

 

Success!
Luc

Thank you so much Luc 🙂

LucMeekes
23-Emerald III
(To:Sarp22)

You're welcome.

 

Where I wrote 'result' it should have been 'return'.

But you understand now, I guess.

 

Luc

Top Tags