Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Passing Java returned values to Matlab as variables ...

Subject: Passing Java returned values to Matlab as variables ...

From: Animesh Pandey

Date: 21 May, 2011 19:22:02

Message: 1 of 2

import java.io.*;

class ConCat {

static String concat(String s1, String s2) {
   String C;
   C = s1 + s2;
   return C;
}

public static void main(String args[]) {
    String a, b ,c;
    a = "Animesh ";
    b = "Pandey";
    c = concat(a, b);
    System.out.println(c);
}
}

I wish to use the returned value of the above program as a string variable in Matlab.
How should I do it ?
Thanx ! :)

Subject: Passing Java returned values to Matlab as variables ...

From: Ed Yu

Date: 27 May, 2011 19:54:06

Message: 2 of 2

Animesh,

Here is what you should do:

.
.
.
cc = ConCat(); % instantiate java class Concat
newJavaString = ConCat.concat('s1','s2');
newMatlabString = char(newJavaString);
.
.
.

Ed.

"Animesh Pandey" wrote in message <ir93cq$5ve$1@newscl01ah.mathworks.com>...
> import java.io.*;
>
> class ConCat {
>
> static String concat(String s1, String s2) {
> String C;
> C = s1 + s2;
> return C;
> }
>
> public static void main(String args[]) {
> String a, b ,c;
> a = "Animesh ";
> b = "Pandey";
> c = concat(a, b);
> System.out.println(c);
> }
> }
>
> I wish to use the returned value of the above program as a string variable in Matlab.
> How should I do it ?
> Thanx ! :)

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us