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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

11-Garnet

## eliminate some values

how can I fix this:

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

1 ACCEPTED SOLUTION

Accepted Solutions
24-Ruby V
(To:YA_10963798)

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

4 REPLIES 4
24-Ruby V
(To:YA_10963798)

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

11-Garnet
(To:Werner_E)

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.

24-Ruby V
(To:YA_10963798)

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.

11-Garnet
(To:Werner_E)

thank you for your great help

Announcements
Top Tags