Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Java and Matlab - URGENT

Posted on 2006-04-19
Medium Priority
Last Modified: 2016-02-10

There was this program in matlab which was converted to java. My problem is that I am not getting the exact results like the matlab version .  For example, if I were to run it 5 iterations , it is somewhat similar..and If i were to run it for 500 iterations..the result is not really similar...

My question is that lets  say I use  the Java's nextGaussian, nextFloat to replace the Matlab randn,rand..

Would the result be different because I am using different languange.....
Matlab              Java
randn              nextGaussian()
rand                nextFloat()
Question by:Jasbir21
  • 3
  • 3
  • 2

Author Comment

ID: 16486159
Is it possible to have a program converted and display the exact same results....

Expert Comment

ID: 16486377
Hi ,

The methods you are using are random number generators.
So the results may not be the same.

If you can tell more details abt your class requirement then we can help you

LVL 30

Expert Comment

by:Mayank S
ID: 16486969
Random numbers generated will anyway always change, that is why they are 'random'. Did you expect to see the same numbers getting generated everytime?
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 16488633
actually, the random generators are the core of the program and is used to simulate a simulation. My question, lets say i program is converted from matlab to java, does it behave the same way....

For example,in Matlab i use rand, but in java is nextFloat()...both are random generators...but would the values produced by the exact same...i know that if it is random generators, it is not going to produce the values at that same time..

I mean lets say Matlab produces value 0.789 and the number of times it produces it would be different than java right ?? pls advice..
LVL 30

Expert Comment

by:Mayank S
ID: 16488747
>> but would the values produced by the exact same

I guess not.

>> I mean lets say Matlab produces value 0.789 and the number of times it produces it would be different than java right

I think so.

Author Comment

ID: 16494179
Is there a way to confirm coz I need to run tests to explain why is it not similar ?

Accepted Solution

avinthm earned 200 total points
ID: 16494999
when you run your application in matlab, even then u cant predict what rand function is going to return.
random number generation is the same, regardless of any language.
one cant predict the number that would be generated.

i think this explaination would be more convincing. :)
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 200 total points
ID: 16495099
>> Is there a way to confirm coz I need to run tests to explain why is it not similar ?

The simple means to do it is to run 2 simple programs (one random number generator in Java and one in MatLab) a number of times and see the output for yourself.

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question