Posts

Showing posts from November, 2021

exception handling in matlab - try catch -- MatLab

 exception handling in matlab - try catch -- MatLab When exception occurs, how to handle it? using exception handling keyword try , catch syntax: try      <statement1> catch <exceptionName>      <exception handling statement1> end [NOTE] Great importance. Please pay a lot of attention on it. (1) Unlike C language, there can exist 1 catch block for each 1 exception handling in matlab. (2) Like C language, there can exist nested try , catch , end. (3) UnLike C language, in matlab, if you wanna do different thing according to different exception. You can only determine that in catch block with conditional statement (such as if , switch). more details on: Execute statements and catch resulting errors - MATLAB try catch (mathworks.com)

cospi(x) v.s. cos(pi*x) -- MatLab

   cospi(x) v.s. cos(pi*x) -- MatLab I mentioned the sinpi(x) v.s sin(pi*x) in my article. sinpi(x) v.s. sin(pi*x) -- MatLab (matlabgeeksforgeeks.blogspot.com)  (My article) this has similar to that. cos(x) returns the same result as cos(pi*x) but cospi(x) computes accuracy than cos(pi*x). Because pi in MatLab approximately the pi in math. more details on: Compute cos(X*pi) accurately - MATLAB cospi (mathworks.com)

sinpi(x) v.s. sin(pi*x) -- MatLab

 sinpi(x) v.s. sin(pi*x) -- MatLab sinpi(x) returns the same result as sin(pi*x) but sinpi(x) computes accuracy than sin(pi*x). Because pi in MatLab approximately the pi in math. more details on: Compute sin(X*pi) accurately - MATLAB sinpi (mathworks.com)