Conversion from Mathematica to Matlab

In summary, the conversation discusses converting a Mathematica code to Matlab, with the speaker being new to both the forum and programming. They are struggling with understanding how to translate certain lines of code, and mention that the code is from Mathematica 5.0. The conversation also suggests reading a Mathematica manual and potentially loosely basing the new code off of the old one. The issue of potential discrepancies between languages is also brought up.
  • #1
Juan Angel
1
0
Hello!.
I am new to the forum and I am also a newbie to programming. I want to convert a Mathematica code to Matlab, but I don't understand how to translate these lines. This code is Mathematica 5.0.

defvar := Module[{a}, Clear[ cN, cNf, ginix ]; Clear[ Nh, Nhf, gini ]; cN = Array[Nh, dim]; cNf = Array[Nhf, dim]; ginix = Array[gix, steps];]

where dim = 1000; steps = 1.

I thank you very much!
 
Physics news on Phys.org
  • #2
Why not read a Mathematica manual, as these seem like core language features that you need to understand in order to effect a translation?

Sometimes though it's better to have your new program loosely based on the old as in you understand the algorithm used in the old one and then just write one in your new language whatever it may be.

Oftentimes, the devil is in the details where your translation gets looping off by one because it starts with 1 vs 0 or a division operator is type-based (int for ints, float for floats) vs always returns a float...
 

1. What is the main difference between Mathematica and Matlab?

Mathematica is a symbolic computation software, while Matlab is primarily used for numerical computations. This means that Mathematica focuses on manipulating mathematical expressions and equations, while Matlab specializes in solving numerical problems.

2. Can I easily convert code from Mathematica to Matlab?

It is possible to convert code from Mathematica to Matlab, but it may not always be a straightforward process. Some functions and features may have different names or may not have an equivalent in the other software. It is important to carefully review and test the converted code to ensure its accuracy.

3. What are the advantages of converting from Mathematica to Matlab?

Converting from Mathematica to Matlab allows for easier collaboration with others who may be more familiar with Matlab. Matlab also has a larger user community and more readily available resources, making it a more popular choice for certain applications.

4. Are there any limitations when converting from Mathematica to Matlab?

Yes, there may be some limitations when converting from Mathematica to Matlab. As mentioned before, some functions and features may not have an equivalent in the other software. Additionally, the syntax and structure of the code may need to be adjusted to fit the rules of Matlab, which could impact the overall functionality of the code.

5. Is it possible to convert back from Matlab to Mathematica?

Yes, it is possible to convert code from Matlab back to Mathematica. However, just like converting from Mathematica to Matlab, it may not be a seamless process and there may be limitations. It is important to carefully review and test the converted code to ensure its accuracy and functionality.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
9K
Back
Top