Why Matlab only run the "else" function equation even "a" fulfils the condition in "if" function? The graph is plotted based on the equation in "else" function only no matter whether "a" is less than 198 or not.
If you are on R2018a you will see an m-lint warning thata is a non-scalar operator (and maybe earlier show it as well). Theif statement uses an implicit call toall if you put a logical array as a parameter. Pre-allocate and use indexing. Also, you are overwriting all your data each and every loop.
a_=a( a<198 );
y ( a<198 )=113+113*(cos(pi*a_/200));