Mathematica to MATLAB translation

Click For Summary
SUMMARY

The discussion focuses on translating Mathematica's Table function into MATLAB for efficient data analysis. Users suggest avoiding loops due to performance issues when handling large datasets. Instead, they recommend defining the expression as a function and utilizing MATLAB's arrayfun for vectorized operations. A specific example provided includes creating a vector and applying a function directly to it, demonstrating a more efficient approach.

PREREQUISITES
  • Familiarity with Mathematica's Table function
  • Understanding of MATLAB's arrayfun function
  • Basic knowledge of vector operations in MATLAB
  • Experience with function definitions in MATLAB
NEXT STEPS
  • Research how to define anonymous functions in MATLAB
  • Learn about vectorization techniques in MATLAB for performance optimization
  • Explore MATLAB's arrayfun and its applications
  • Study the differences between Mathematica and MATLAB syntax for common functions
USEFUL FOR

This discussion is beneficial for data analysts, MATLAB users transitioning from Mathematica, and anyone looking to optimize their MATLAB code for large dataset processing.

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 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 32 ·
2
Replies
32
Views
4K
Replies
6
Views
4K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
3
Views
4K
  • · Replies 4 ·
Replies
4
Views
4K