MATLAB Mathematica to MATLAB translation

AI Thread Summary
To translate Mathematica's Table[expr, {i, a, b}] to MATLAB, users suggest creating a function f of i and generating a vector from a to b. Instead of using loops, which are inefficient for large datasets, applying the function with arrayfun is recommended. One user demonstrated a simple approach by defining a vector and directly applying a function to it. This method enhances performance and simplifies the translation process. Efficient translation techniques are crucial for handling large datasets in MATLAB.
RYYJDEH
Messages
3
Reaction score
0
Hi, I have some Mathematica code I want to translate in Matlab, does anyone know how to translate the Table [expr,{i,a,b}]to Matlab? I made one with a loop, but loops are very slow and I am going to analyze large datasets with the functions.
 
Physics news on Phys.org
RYYJDEH said:
Hi, I have some Mathematica code I want to translate in Matlab, does anyone know how to translate the Table [expr,{i,a,b}]to Matlab? I made one with a loop, but loops are very slow and I am going to analyze large datasets with the functions.

I'm neither a Matlab nor Mathematica user, however, could you rewrite expr as a function f of i, create a vector running from a to b (something like i = a:b, perhaps?) and then apply f to i using arrayfun (maybe you could use expr as an anonymous function?

NR
 
Even simpler, I just created a vector say k=1:40 and then wrote my function say 5*k+12.
 

Similar threads

Replies
1
Views
2K
Replies
5
Views
3K
Replies
32
Views
4K
Replies
12
Views
3K
Replies
7
Views
2K
Replies
4
Views
4K
Back
Top