MATLAB Conversion from Mathematica to Matlab

AI Thread Summary
A user seeks assistance in converting Mathematica code to MATLAB, specifically for a module that involves defining variables and clearing them. Key points in the discussion highlight the importance of understanding core Mathematica features for effective translation. It is suggested that rather than a direct translation, it may be beneficial to grasp the underlying algorithm and then implement it in MATLAB. Additionally, attention is drawn to potential pitfalls in translation, such as differences in indexing (1-based vs. 0-based) and type handling in mathematical operations, which can lead to errors if not carefully managed.
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
Views
3K
Replies
7
Views
2K
Replies
4
Views
4K
Replies
2
Views
5K
Replies
1
Views
2K
Replies
1
Views
2K
Replies
3
Views
4K
Replies
5
Views
1K
Back
Top