MATLAB Answers

Optimization! Divide a vector by each element of another vector!

1 view (last 30 days)
M G on 28 Nov 2013
Commented: M G on 1 Dec 2013
Dear all,
I would like to optimize my code which looks like this:
for n = 1:N
prt1(n,:) = exp(exp1/n^2);
exp1 is a vector of (1,2e4) and N = 2e4.
As you see the loop above works fine but the problem is heavy computation which takes extremely long time. Is there any way that I can vectorize n? By that I need to divide each element of exp1 by the 1st element of n and then 2nd, 3rd, ... nth element of n.
Any hint is appreciated :)
All the best
PS: Any good source in general for the MATLAB optimization??


Sign in to comment.

More Answers (0)