MATLAB Answers

Short way to write this function?

5 views (last 30 days)
Does anyone know of a solution to this problem?
function[y]=rayleigh_product(x,x2,x3,x4) % For up to 55 storm steps (threshold = 4 in the original case)
global SDSRp_ Tz_Tz_
And it goes on till 55 parts. The code works now, but it would be useful to have the option of just doing the product of any number of functions. I.e, if I want to do the same analysys with a different data set.

Accepted Answer

Walter Roberson
Walter Roberson on 19 Mar 2019
Edited: Walter Roberson on 19 Mar 2019
y = prod(arrayfun(@(IDX) 1-exp(-0.5*(x./SDSRp_(x2,x3,x4,IDX).^(10800./Tz_Tz_(x4,IDX+1)))), 1:55));
This assumes that SDSRp_ and Tz_Tz_ are functions. If they were arrays then there is more potential for vectorization.
Is it practical to rewrite the two functions to accept a vector for the last parameter?
José Antonio Torres
José Antonio Torres on 19 Mar 2019
Thank you so much Walter! This is just what I needed

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!