mathematica to matlab converter

Hello. I need to convert Mathematica program to matlab. I have tried tomatlab function but doesn't know how to use it.I only need to convert some expressions.
suggest a solution

Respuestas (2)

Walter Roberson
Walter Roberson el 14 de En. de 2012

1 voto

In such situations the method that is most effective for me is understanding what the source code is doing and rewriting the functionality in the second language.

6 comentarios

LOKESH
LOKESH el 14 de En. de 2012
I totally agree with that but i can't do the partition function?How to do that in matlab.Flat() is available in matlab,what i need to do for Partition()?
Walter Roberson
Walter Roberson el 14 de En. de 2012
Editada: Walter Roberson el 26 de Mzo. de 2023
"Your Honor, the council is assuming facts that are not in evidence."
In other words, do not assume that people will refer back to and remember your previous postings.
"I need to convert the following expressions into matlab:
B=Flatten[B];
L=partition[L,length];"
I do not find any Mathematica function named "partition". There is a "Partition" function though, http://reference.wolfram.com/mathematica/ref/Partition.html . The equivalent to that function would depend upon which data structure you wanted. reshape() might be appropriate, or mat2cell() might be appropriate.
LOKESH
LOKESH el 16 de En. de 2012
Thanks Walter.
For Flattening the image matrix i did:
B=B(:);
For partition i am getting error in reshape
i want the L to a square image of size length
I did:
L1=reshape(L,length);
ERROR:
??? Error using ==> reshape
Size vector must have at least two elements.
Error in ==> rk4_CHEN at 140
L1=reshape(L,M);
OR
L1=reshape(L.length,length);
ERROR:
??? Error using ==> reshape
To RESHAPE the number of elements must not change.
Error in ==> rk4_CHEN at 140
L1=reshape(L,M,M);
Suggest solution
Walter Roberson
Walter Roberson el 16 de En. de 2012
I suspect you want
L1 = reshape(L, length, []).' ;
And to be consistent with Mathematica, I suspect that your Flatten should be
B1 = reshape(B', [], 1);
In both of these cases, I am presuming that you are storing row-wise (as Mathematica would) rather than column-wise (as MATLAB would.)
LOKESH
LOKESH el 18 de En. de 2012
I am going from scratch as i am unable to get from above solution.
Please suggest what following lines mean in mathematica:
pixelvalues=A[[1,1]];
Dimensions[pixelvalues]
lg=Length[pixelvalues]
Where A is jpeg image..
as i am confusion of that does first line mean pixel value at point A(1,1).
Walter Roberson
Walter Roberson el 18 de En. de 2012
It has been pretty much a decade since I did any serious Mathematica programming; it would be easier for you to look up the functions on the Wolfram site.

Iniciar sesión para comentar.

NNM
NNM el 26 de Oct. de 2017
Movida: DGM el 12 de Abr. de 2023

1 voto

Too old a thread, but this answer may be helpful for some visitor. You can use ToMatlab package built for mathematica http://library.wolfram.com/infocenter/MathSource/577/ Usage: Place the file in applications folder of your base directory.
<<ToMatlab`
SOME EXPRESSION //ToMatlab

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Preguntada:

el 14 de En. de 2012

Movida:

DGM
el 12 de Abr. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by