matlab and java

Discussion in 'Programmer's Corner' started by Mathematics!, Feb 8, 2011.

  1. Mathematics!

    Thread Starter Senior Member

    Jul 21, 2008
    I am trying to call matlab functions from java.
    I am using the deploytool which creates a .jar file and when I execute it I get alot of errors saying

    Error using ==> eval
    undefined function or variable x

    in the matlab code I have an .mfile that has a function for instance

    Code ( (Unknown Language)):
    2. function y = average(x)
    3. % AVERAGE Mean of vector elements.
    4. % AVERAGE(X), where X is a vector, is the mean of vector
    5. % elements. Nonvector input results in an error.
    6. [m,n] = size(x);
    7. if (~((m == 1) | (n == 1)) | (m == 1 & n == 1))
    8.     error('Input must be a vector')
    9. end
    Basically I am getting alot of errors saying undefined varible or function x.

    I know at the matlab interpreter I would first have to
    declare x
    then call the function average(x) with it.

    How would I resolve these issues in my deploytool built jar file.

    Thanks for any help
    I believe this would take somebody experienced in matlab to answer.