Mathematica to MATLAB translation

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 5K views
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.