In Matlab, you can use abs
function to calculate absolute values of a matrix/vector.
For example, consider the following matrix:
main.m23 chars2 lines
To calculate the absolute values of matrix A
, you can do the following:
main.m16 chars2 lines
This will give you the following result:
main.m46 chars4 lines
Similarly, to calculate the absolute value of a single number in Matlab, you can use the abs
function as follows:
main.m24 chars3 lines
The output will be:
main.m15 chars3 lines
gistlibby LogSnag