retrieve matlab result in java -


I use matlab in my project and I want to get the result of matlab in java. Just want the result I want to retrieve the result of the file which I create in Java in matlab. I use this code, but as a result I get results in the matlab window and I just want to remove the result in java is this code

  public class matlab {personal static file myMATLABScript; // my static file myMATLABScript; Public Static String Runscript (File Script Name) {String Output = ""; String error = ""; Try {// string command tyrone = "matlab-r my matlappubs-anodisplay" lt; + ScriptName; String command tiren = "matlab-nosplash-r mymatabiptry-nodisplay-nodesktop & lt;" + Script name; Println (commandToRun); Process p = runtime.gettime (). Exec (commandToRun); String s; BufferedReader stdInput = new BufferedReader (new InputStreamReader (p.getInputStream ())); BufferedReader stdError = new BufferedReader (new InputStreamReader (p.getErrorStream ())); // command system.out.println ("\ n here is the standard output of the command: \ n"); read the output; While ((s = stdInput.readLine ()) = null) {output = s + "\ n"; Println (s); //System.out.println(what's the problem ");} // Read any error with the tried command // system.out.printline =" \ "here is the standard error of the command (if any): \ N); while ((s = stdError.readLine ()) =! Null {error = s + "\ n"; System.out.println (s);}} Catch (exception e) {System.out.println E.printStackTrace (); System.exit (-1);} Returning Output + Error;} Public Static Zero Main (String [] Args throws IOException {matlab m = "exception occurred - here I know: New matlab (); matlab.runScript (myMATLABScript);}}  

can you help me ?

What OS are you running on the MetLap App Differently behave differently on different OS I believe that you are on Windows because you mention "matlab window", even if you are going through "nodesktop." In windows, matlab naturally has a GUI app and stdin / stdout are useless .

Try writing your file to a file, which is an environment variable, filters Rk you pass the Mamatlabskript, or well-known path. Then read that file instead of the matlab's standout. Use only "-R" switch, "& lt;" No. It will be portable in the OS and you can find it easy to parse because the additional matlab command window output will not output to the output file.

You have completed the "-Wit" your Matlab script. The usual Matlab.exe invocation on Windows will return immediately. Make sure your script ends with "exit ()" or Matlab will run indefinitely, after waiting for your user to input the script.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -