Conversion from Mathematica to Matlab

Click For Summary
SUMMARY

The discussion focuses on converting Mathematica 5.0 code to Matlab, emphasizing the importance of understanding core language features for effective translation. Key points include the need to grasp the algorithm behind the original code rather than performing a direct line-by-line translation. Participants highlight potential pitfalls such as indexing differences and type-based operations that can lead to errors during conversion.

PREREQUISITES
  • Understanding of Mathematica 5.0 syntax and features
  • Familiarity with Matlab programming concepts
  • Knowledge of array handling in both Mathematica and Matlab
  • Awareness of indexing differences between programming languages (1-based vs 0-based indexing)
NEXT STEPS
  • Research Matlab array initialization and manipulation techniques
  • Learn about type handling in Matlab, especially regarding integers and floats
  • Explore algorithm design principles for translating code between languages
  • Study common pitfalls in code translation, focusing on indexing and loop structures
USEFUL FOR

This discussion is beneficial for programmers transitioning from Mathematica to Matlab, particularly those new to programming and seeking to understand language-specific nuances in code translation.

Juan Angel
Messages
1
Reaction score
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
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...
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 2 ·
Replies
2
Views
5K
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K