Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
how can I fix this:
if (a )is less than zero the answer should alwyas be zero
Solved! Go to Solution.
You don't need a range variable w !
What your program tried to achieve can be done that way:
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:
Prime 10 worksheet attached
You don't need a range variable w !
What your program tried to achieve can be done that way:
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:
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.
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.
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:
Calculation of b'' now works OK, but of course b'' now has one element less than vector a.
thank you for your great help