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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

eliminate some values

YA_10963798
11-Garnet

eliminate some values

YA_10963798_0-1716462590900.png

how can I fix this:

if (a )is less than zero the answer should alwyas be zero 

 

1 ACCEPTED SOLUTION

Accepted Solutions

You don't need a range variable w !

Werner_E_0-1716468267651.png

What your program tried to achieve can be done that way:

Werner_E_1-1716468505322.png

The assignment in the first line is mandatory, otherwise you would have to use an else-statement to assign the (positive) value of a[w to the Result vector.

The same effect could be achieved using a boolean expression (a>0) and vectorization:

Werner_E_2-1716468635139.png

Prime 10 worksheet attached

 

 

View solution in original post

4 REPLIES 4

You don't need a range variable w !

Werner_E_0-1716468267651.png

What your program tried to achieve can be done that way:

Werner_E_1-1716468505322.png

The assignment in the first line is mandatory, otherwise you would have to use an else-statement to assign the (positive) value of a[w to the Result vector.

The same effect could be achieved using a boolean expression (a>0) and vectorization:

Werner_E_2-1716468635139.png

Prime 10 worksheet attached

 

 

I know it is wrong to use w in this manner becuase the first value is less than origin , however I have to use this function like this. How can I tackle this issue?

I often face it.

YA_10963798_0-1716474030546.png

 

Obviously you are trying to use vector elements that are BEFORE the first and AFTER the last, i.e. they do not exist.

Not sure what you are trying to achieve, but from a pragmatic point of view I would say that you have to start your w-loop after the first and stop it before the last possible vector index.

Werner_E_2-1716475792413.png

Ooops, we get an error as of incompatible units! Reason is that Prime insists on units for zero values, too. So we have to change the program which replaces negative lengths by zero to replace them by zero meter:

Werner_E_3-1716475831518.png

Calculation of b'' now works OK, but of course b'' now has one element less than vector a.

Werner_E_1-1716475734880.png

 

thank you for your great help

Top Tags