Slow piece of code

1 view (last 30 days)
Aeronomy
Aeronomy on 28 Jan 2014
Commented: per isakson on 28 Jan 2014
Hello everyone. I have a working piece of code. But for large values it is really slow. Code is pasted below:
for i = 1:T
[rowX1,colX1] = find(XI==X_trace1(i),1);
[rowY1,colY1] = find(YI==Y_trace1(i),1);
if isempty(colX1) || isempty(rowY1)
display('out of grid')
else
lh1=m_quiver(XI(rowY1,colX1),YI(rowY1,colX1),UI(rowY1,colX1)*0.00027,VI(rowY1,colX1)*0.00027,0);
hq1(i)=quiver(XI(rowY1,colX1),YI(rowY1,colX1),0.00027*UI(rowY1,colX1)/cos(YI(rowY1,colX1)*pi/180),VI(rowY1,colX1)*0.00027,'Autoscale','off');
end
end
XI and YI (also UI and VI) are big matrices (2200 x 2200) produced using meshgrid. hq1 is the resultant array of this loop. For large value of T, this code takes long time. I would have no problem if this was the only part of my full code, But i have 10 similar pieces in full code. Is there any way to make this piece of code run faster. I will appreciate any kind of suggestion to improve this code.
thanks
  6 Comments
per isakson
per isakson on 28 Jan 2014
what does profile say?
per isakson
per isakson on 28 Jan 2014
"The profile function helps you debug and optimize MATLAB® code files by tracking their execution time." Run
doc profile

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!