Posts

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)

basic introduction to table in MatLab

basic introduction to table in MatLab [introduction] What is table? A table is a kind of array in tubular form whose name is it column and it can contain elements with different types. How to create a table? keyword table. Type Conversion. Remember that t1->t2 will be represented as <t1>2<t2> array2table  homogenous array to table. cell2table cell array to table. struct2table structure array to table timetable2table timetable to table. table2array table to homogeneous array. table2cell table to cell array. table2struct  table to structure array. table2timetable table to timetable. How to subscript the type? keyword vartype. [syntax] V=vartype(<type>) V will present as <type> e.g. S = vartype( 'numeric' ); T2 = T(:,S) T will converted as numeric type then assign it to the variable T2. How to convert table to a specified type? keyword convertvars or keyword that I mentioned above. [syntax] T2 = convertvars(T1,vars,dataType) will convert the specified...

comment in MatLab

 inline function in MatLab What is inline function? Inline function in function is like macro in variable. When you use Iinline function, the interpreter will expand the inline function to your code. How to create inline function? keyword inline. [syntax] inline a b will be expanded as b given a [NOTE] It must be seperated by space. more details on: (Not recommended) Construct inline object - MATLAB inline (mathworks.com)

Anonymous Function in MatLab

 Anonymous Function in MatLab [introduction] What is Anonymous Function? It is a function without name. But it is not store in program file. How to create an Anonymous Function? @ [syntax] @funcName content e.g. f=@power2(x) x*x f(x)=power2(x) f(5) will return 5*5 more details on: Anonymous Functions - MATLAB & Simulink (mathworks.com)

a convenient type to record lots of value in MatLab -- cell matrix

a convenient type to record lots of value in MatLab -- cell matrix How to create a cell matrix in MatLab? Way1: cell method Way2: {} more details on: Cell array - MATLAB (mathworks.com) Type Conversion. Remember that when type t1 is converted to type t2 (t1->t2), the keyword is <t1>2<t2> num2cell number array to cell array. char2cell  char array to cell table2cell table to cell array. struct2cell structure array to cell array. mat2cell array to cell array whose cells contains subarrays. cell2num cell array to number array cell2char cell array to char array. cell2table cell array to table. cell2struct cell array to struct array. cell2mat cell array to ordinary array of underlying data type. How to check a type of variable is a cell matrix? iscell() method How to apply each cell in cell array? cellfun method [syntax] cellfun(funcName,arg1) cellfunc(funcName func,arg1) You can declare a anomynous function within the cellfunc method. more details on: Apply function to ea...