which one is faster for loop or switch

4 次查看(过去 30 天)
Hi, I want to know which looping is better from programming point of view i.e. for loop or switch.
In my coding I have used switch and case , and it is taking lots of time. I am using it for optimization.
Kindly help me out in order to improve the speed of my code.
Any suggestion is appreciated.
Thanks, Suraj
  1 个评论
Stephen23
Stephen23 2015-4-9
编辑:Stephen23 2015-4-9
Considering one single switch or loop in isolation might not be the best way to optimize code. Upload your whole Mfile and we can see at it in context! There might be other improvements and simplifications that you have not considered, that make the switch/loop irrelevant or insignificant.

请先登录,再进行评论。

采纳的回答

Thomas Koelen
Thomas Koelen 2015-4-9
read in the comments. (I guess you are talking about if statements and not loops)
  4 个评论
Suraj Srivastava
Suraj Srivastava 2015-4-9
suppose I am using it in Optimization process and there is around 10000 iterations.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by