# What is the easiest way to import a text matrix into Matlab?

1 view (last 30 days)
Mehdi on 10 Sep 2022
Commented: Walter Roberson on 10 Sep 2022
HI,
I exported a symbolic matrix from Maple as a text file, and now want to import it to Matlab.
What is the easiest way to import it to Matlab?
Is there any special ready to use function to read it and put in a matrix?
Here I have put two line of that text file, which each line represents each raw of the (2*6) matrix.
x*y*z 1/2*tau[2] sin(x*y*z) ln(x*y*z) tau*exp(x*y*z) sin(x+y)+cos(x+y)
x^2+1 x^2+1/sin(x*y*z) 2*exp(y) tau diff(f(x,y,z),x) int(f(x,y,z),x)

Walter Roberson on 10 Sep 2022
or
Question:
Have you considered using Maple's CodeGeneration[Matlab] function ?
Walter Roberson on 10 Sep 2022
You would need to use str2sym() to convert the entries to symbolic.
However, your input includes '1/2*tau[2]' which is not valid MATLAB symbolic expression.
It also includes ln(x*y*z) -- remember that the MATLAB log is log() not ln()

### Categories

Find more on Lengths and Angles in Help Center and File Exchange

R2021b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!