Monday, June 22, 2015

Useful chunks of MATLAB code

1. Nominal to numeric mapping

The following code will convert from a nominal value vector to a numeric value vector.
Example: suppose that Yno is the nominal value vector and Ynum is the numeric value vector. The casting line is as follow:
Ynum = double(nominal(Yno));

2. Sum one field of a struct

The following code will compute the summation from the field "true" of a struct called "recall".
result=sum(cell2mat({recall.true}));
(Nguyen My - 2015/06/23)

0 comments:

Post a Comment