Posts

How to get a number with significant k-digits in MatLab? - vpa -- MatLab

 How to get a number with significant k-digits in MatLab? - vpa -- MatLab How to get a number with significant k-digits in MatLab? [Ans] vpa [syntax] vpa(x) vpa(x,a) [description] vpa(x,a)  It will return x with significant k-digits. The default value of k is digitOld where it is 32 by default. You can also set the value digitOld through the keyword digits more details on digits: Change variable precision used - MATLAB digits (mathworks.com) [NOTE] Don't know about the meaning of significant k-digits. You can see the link in the section below which named "chinese definition". This link gives a great definition. more details on: MathWork official doc Variable-precision arithmetic (arbitrary-precision arithmetic) - MATLAB vpa (mathworks.com) chinese definition matlab中vpa函數 matlab有效數位 – MATLAB中文論壇 (ilovematlab.cn) code: clear clc fprintf( "pi in 5 precision in a float-point number.\n" ) pi fprintf( "pi in 32 precision in a float-point number.\n" ) pi32 = ...

How to set a function that can return different value for different range in MatLab? - piecewise -- MatLab

 How to set a function that can return different value for different range in MatLab? - piecewise -- MatLab [Ans] piecewise command [Description] I think explanations of matlab help doc are I think I can not use greater way to describe --- help for sym/piecewise  --- piecewise  Conditionally defined symbolic object PW = piecewise (CONDITION1, VAL1, CONDITION2, VAL2, ..., <OTHERWISEVAL>) Create a conditionally defined symbolic object. It equals the k-th value if the k-th condition holds and the first k-1 conditions are false. If all conditions are false, it equals otherwiseVal. The final argument otherwiseVal may be omitted; it defaults to sym(NaN). In contrast to an if statement, the truth value of the conditions need not be decidable at the time the conditional object is defined. [Syntax] pw = piecewise(cond1,val1,cond2,val2,...,<otherwiseVal>) Type of <otherval> must be constant. If <otherVal> was not given...

How to set a range in symbolic variable in MatLab? - assume -- MatLab

 How to set a range in symbolic variable in MatLab? - assume -- MatLab  How to set a range in symbolic variable in MatLab? [Ans] assume command  How to set a range in symbolic variable in addition in MatLab? [Ans] assumeAlso command  How to look at current assumption of the given variable? [Ans] assumptions command assumptions [Description] take a look at current assumptions of x. [Syntax] assumptions(x) assumeAlso [Description] It is similar to assume function, but it is  additive. [Syntax] Same as assume function. assume [Description] assume function can assume  a symbolic variable between specific range or type with given expression. It uses some simple conceptions of set. When I comprehend it, I uses some simple conceptions of set. [Syntax] (1)assume(<cond>) (2)assume(<expre>,<set>) (3)assume(<expre>,'clear') (1)assume(<cond>) the state <cond> will be set to be valid. (2)assume(<expre>,<set>) the state of ...

How to check an inequality of a variable is true or not in MatLab? isAlways -- MatLab

 How to check an inequality of a variable is true or not in MatLab? isAlways -- MatLab How to check an inequality of a variable is true or not in MatLab?  e.g.  check abs(x)>=0 where x is any number. or  check (2*x+1>=0) where x>=0; [Ans] isAlways command [Description] isAlways(<expre>)  it will return true if the expression <expre> is Alaways true. it will return false if the expression <expre> is Alaways false. If the expression <expre> is Unknown (i.e. it is not certain ) (i.e.it maybe true or false), it will throw warning (by default ,without other argument) and return false. you can change the default behavoiur by setting its <Name> [Syntax] isAlways(<expre>); isAlways(<expre>,<Name>,<Value>); Set <Name> as <Value>. e.g. is on at buttom. more details on: Check whether equation or inequality holds for all values of its variables - MATLAB isAlways (mathworks.com) e.g. clear clc %true s...

float-pointing number in MatLab -- MatLab

float-pointing number in MatLab -- MatLab properties flintmax abbreviation of float largest integer max. f= flintmax  returns the largest consecutive integer in IEEE ®  double precision, which is  2^53 . Above this value, double-precision format does not have integer precision, and not all integers can be represented exactly. f = flintmax(precision)  returns the largest consecutive integer in IEEE single or double precision.  flintmax  returns  single(2^24)  for single precision and  2^53  for double precision. source: Largest consecutive integer in floating-point format - MATLAB flintmax (mathworks.com) intmin abbreviation of integer min. smallest value of specified integer type. v = intmin('classname')  is the smallest positive value in the integer class  classname .  Valid values for the string  classname  are 'int8' 'int16' 'int32' 'int64' 'uint8' 'uint16' 'uint32' 'uint64' [NOTE] intmin('int32')  is th...

complex number in MatLab -- MatLab

 complex number in MatLab -- MatLab properties i imagery unit it is equivalent to sqrt(-1). j same as i imagery unit it is equivalent to sqrt(-1). method complex create a complex number. syntax (1)z=complex(a,b); is equivalent to z=a+b*i; (2)z=complex(x); will return x+0*i; where x is a real number. [NOTE] In this case, isreal(z) will return false  because z is a complex number not a real number; (3)z=complex(x) will return identical of x where x is a complex number.

real field in MatLab -- MatLab

 real field in MatLab -- MatLab properties realmin smallest normalized floating-point number. realmax largest positive floating-point number.  method real get real part of the given number. isreal check it is real. return true when it is a real number. otherwise, return false. source: Real part of complex number - MATLAB real (mathworks.com)