How to evaluate a multivariable function at different value of the variable effectively ?
显示 更早的评论
I am having a function f() this function is complicated function and its varialbles are epxi, beta, a1_t2, a2_t3, and xai. All of these variable are from 0 to 1. However, because some NaN problem, I decided to change it a little bit that is all the variable are from 0.1 to 0.9.
epxi = [0.1:0.1:0.9];
beta = [0.1:0.1:0.9];
a1_t2 = [0.1:0.1:0.9];
a2_t3 = [0.1:0.1:0.9];
xai = [0.1:0.1:0.9];
I want to evaluate my function f at all posible combination of epxi, beta, a1_t2, a2_t3, and xai to find out the max value effectively ( I have a multi-cores computer) but dont know how to do this.
Currently, my implemenation is quite naive and bad:
for c1 = 1:length(epxi)
for c2 = 1:length(beta)
for c3 = 1:length(a1_t2)
for c4 = 1:length(a2_t3)
for c5 = 1:length(xai)
temp = f(epxi(c1),beta(c2),a1_t2(c3),a2_t3(c4),xai(c5);
result = [result temp];
end
end
end
end
end
Particularly, f() here is the function of interest. I store the evaluation to an array that keep expanding. The expanding array is the variable result.
Note that this function f is not a symbolic function.
I intended to use the built-in matlab function max on the result vector but I understand that this implementation is not efficient. I guess that some pre-allocation of the variable result would be more efficient but fail to do so.
Please help me with this !
Thank you for your enthusiasm !
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!