how can i make loop run faster?
1 view (last 30 days)
I am trying to make a for-loop run faster.
I used matrices for part of my code instead of loops,
but I can't seem to do it for the loop in the last part of the code below.
Because in the .^ part I get the error that says matrix dimension doesn't match.
Any ideas that can help?
d2 = zeros(X.r(1),10^5);
d3 = zeros(X.r(1),10^5);
dd2 = zeros(1000,10^5);
dd3 = zeros(1000,10^5);
Jordan Ross on 9 Jan 2017
As I understand you are trying to eliminate your for-loop so that your code will run faster but are unable to vectorize due to a dimension mismatch. After looking at your code, it seems that sig1 and sig2 are defined as row vectors instead of column vectors. This is causing the dimension mismatch when trying to vectorize. You can take the transpose of sig1 and sig2 as follows:
sig1 = sig1';
sig2 = sig2';