Skip to content

Instantly share code, notes, and snippets.

@smly
Created July 25, 2010 08:57
Show Gist options
  • Select an option

  • Save smly/489432 to your computer and use it in GitHub Desktop.

Select an option

Save smly/489432 to your computer and use it in GitHub Desktop.
use matlab code written by Xiaojin Zhu
#!/bin/sh
# Usage: lp.sh -w W.txt -l L.txt -p result.csv
# * requirement
# http://pages.cs.wisc.edu/~jerryzhu/pub/harmonic_function.m
# and matlab.
MATLAB=matlab
HELP="$0 -w <weight_matrix> -l <label_matrix> -p <predict_matrix>"
while [ -n "$1" ]; do
case "$1" in
-w) shift; w=$1; shift;;
-l) shift; l=$1; shift;;
-p) shift; u=$1; shift;;
-*) echo "illegal option $1"; exit 1;;
*) break;
esac
done
if [ -z "$w" ] | [ ! -e "$w" ] | [ -z "$l" ] | [ ! -e "$l" ]; then
echo $HELP; exit 1
fi
if [ -z "$u" ]; then
echo $HELP; exit 1
fi
echo "
w_file = '$w';
fl_file = '$l';
fu_file = '$u';
%fucmn_file = 'sample_fu_CMN.csv';
W = dlmread(w_file);
fl = dlmread(fl_file);
[fu, fu_CMN] = harmonic_function(W, fl);
csvwrite(fu_file, fu);
%csvwrite(fucmn_file, fu_CMN);" | $MATLAB -nodisplay > /dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment