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:
create java string array from matlab

Subject: create java string array from matlab

From: Adam Chapman

Date: 6 Jun, 2011 18:04:47

Message: 1 of 3

Im trying to call a java class from matlab.

The java class has two inputs:
jboost.controller.Configuration(java.lang.String,java.lang.String[])

The java code is definately running, but not catching the second input
properly, and stops reading the inout at the first whitespace
character in the string.

In matlab my call looks like this:
a=jboost.controller.Configuration('rubbish','-m tree.m')

I think it needs '-m' and 'tree.m' to be 2 elements of a java string
array, hance the [] in the inout format.

Can anyone please comment how to create such an object?

Subject: create java string array from matlab

From: Donn Shull

Date: 6 Jun, 2011 18:54:05

Message: 2 of 3

Adam Chapman <adamchapman1985@hotmail.co.uk> wrote in message <ecefdf7c-aa96-4530-8453-1113c1e02977@d19g2000prh.googlegroups.com>...
> Im trying to call a java class from matlab.
>
> The java class has two inputs:
> jboost.controller.Configuration(java.lang.String,java.lang.String[])
>
> The java code is definately running, but not catching the second input
> properly, and stops reading the inout at the first whitespace
> character in the string.
>
> In matlab my call looks like this:
> a=jboost.controller.Configuration('rubbish','-m tree.m')
>
> I think it needs '-m' and 'tree.m' to be 2 elements of a java string
> array, hance the [] in the inout format.
>
> Can anyone please comment how to create such an object?

Hi Adam,

jsa = javaArray('java.lang.String', 2)
jsa(1) = java.lang.String('-m');
jsa(2) = java.lang.String('tree.m');

good luck,

Donn

Subject: create java string array from matlab

From: Yair Altman

Date: 7 Jun, 2011 15:17:02

Message: 3 of 3

"Donn Shull" <donn.shull.no_spam@aetoolbox.com> wrote in message <isj7oc$4ad$1@newscl01ah.mathworks.com>...
> Adam Chapman <adamchapman1985@hotmail.co.uk> wrote in message <ecefdf7c-aa96-4530-8453-1113c1e02977@d19g2000prh.googlegroups.com>...
> > Im trying to call a java class from matlab.
> >
> > The java class has two inputs:
> > jboost.controller.Configuration(java.lang.String,java.lang.String[])
> >
> > The java code is definately running, but not catching the second input
> > properly, and stops reading the inout at the first whitespace
> > character in the string.
> >
> > In matlab my call looks like this:
> > a=jboost.controller.Configuration('rubbish','-m tree.m')
> >
> > I think it needs '-m' and 'tree.m' to be 2 elements of a java string
> > array, hance the [] in the inout format.
> >
> > Can anyone please comment how to create such an object?
>
> Hi Adam,
>
> jsa = javaArray('java.lang.String', 2)
> jsa(1) = java.lang.String('-m');
> jsa(2) = java.lang.String('tree.m');
>
> good luck,
>
> Donn

Here's another alternative you can try:
a=jboost.controller.Configuration('rubbish', {'-m','tree.m'})

Yair Altman
http://UndocumentedMatlab.com

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