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

I have a problem with Matrixs and if/for loop

SOLVED
Highlighted
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

Re: I have a problem with Matrixs and if/for loop

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

6 REPLIES 6

Re: I have a problem with Matrixs and if/for loop

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

Re: I have a problem with Matrixs and if/for loop

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.  

Re: I have a problem with Matrixs and if/for loop

Look at the difference here:LM_20190725_Program.png

 

Success!
Luc

Re: I have a problem with Matrixs and if/for loop

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

You HAVE to use 'result'.

 

Success!
Luc

Re: I have a problem with Matrixs and if/for loop

Thank you so much Luc Smiley Happy

Re: I have a problem with Matrixs and if/for loop

You're welcome.

 

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

But you understand now, I guess.

 

Luc