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

Indexing functions

SOLVED
Highlighted
Garnet

Indexing functions

First of all a happy prosperous and especially healthy 2019 to all! I have apparently a misunderstanding when to use indexing versus vectorisation. In the attached worksheet indexing works but vectorisation doesn't. Could someone help me out with this because I seem to be lost.

Best regards, Filip

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Indexing functions

When doing calculations where you later want to fill in vectors of data I would strongly recommend to set up all those calculations as functions dealing with scalars only and later call those functions vectorized with the data vectors as arguments.

See attached worksheet.

 

View solution in original post

3 REPLIES 3
Highlighted

Re: Indexing functions

Hi,

 

In the first instance of indexing, f(p,i) returns a single value at any point p and thus can be numerically integrated with respect to "p".


In the second instance of vectorisation, f(p) returns a vector as the result. "p" as an input can be either a single value or a vector of similar size to PA50. It is not possible to numerically integrate a function that returns a vector at every point. The integration thus fails.

 

Cheers

Terry

 

 

Highlighted

Re: Indexing functions

When doing calculations where you later want to fill in vectors of data I would strongly recommend to set up all those calculations as functions dealing with scalars only and later call those functions vectorized with the data vectors as arguments.

See attached worksheet.

 

View solution in original post

Highlighted

Re: Indexing functions

Terry, thank you so much for the clarification as this explains the why.

Werner, thank you for your additional hint. It is indeed a much clearer way to do it the way you propose. I will try to use this not only for this worksheet but also for future ones.

All the best, Filip

 

Announcements