Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: speed up for iteration in every element
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Mike

Posts: 336
Registered: 4/17/07
speed up for iteration in every element
Posted: Oct 11, 2012 8:44 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi

Following code takes a lot of time to execute. It is done element by element, because it needs iteration. Could it be faster by matrix?

X2=X1; % initialize X2
for irow=1:nrow
for icol=1:ncol
diff=9999.;
for it=1:10 % maximum iteration no.
Xout(irow,icol)=1/(1+X2(irow,icol)); % Xout is the output
diff=abs(X2(irow,icol)-Xout(irow,icol)); % define difference between iterations
if(diff>1.e-5) % require further iteration?
X2(irow,icol)=Xout(irow,icol); % initialize the next step
else
continue
end
end
end
end

Thanks.

Mike



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.