Questions tagged [matlab]

Questions related to interoperability between Mathematica and MATLAB, or implementation of MATLAB functionality in Mathematica. This tag is NOT for pure MATLAB question.

Filter by
Sorted by
Tagged with
0 votes
0 answers
21 views

Using `GradientFilter[]` and `GradientOrientationFilter[]` to reproduce Matlab's `gradient()` function

In 'gradient' function in MMA, two methods are given to reproduce Matlab's gradient() function. I thought that ...
user avatar
  • 1,158
3 votes
1 answer
103 views

Use function defined in Mathematica from Matlab

This question is the same as this post which was closed too early to be answered and efforts to reopen it were unsuccessful. How could we use a defined function inside Mathematica from Matlab? With ...
user avatar
  • 5,444
2 votes
0 answers
173 views

Call function defined in Mathematica from Matlab [closed]

Is it possible to call a defined function inside Mathematica like InterpolationFunction[...] from Matlab? Thanks!
user avatar
0 votes
1 answer
99 views

Cannot open MATLAB from MATHEMATICA

I am using MATLAB R18 and MATHEMATICA 12. I downloaded MATlink to the directory generated by the command: ...
user avatar
6 votes
2 answers
432 views

Compare MMA program with MATLAB program by plotting the same equation

Cross-posted in Wolfram Community. Firstly, the MATLAB program is ...
user avatar
  • 93
0 votes
0 answers
77 views

Surface crossing itself plotted from x,y,z data

In Matlab I am generating this surface for example. It is plotted in for loop, so in each iteration I plot one ellipse or whatever itself crossing curve. Number of iteration is high so it produce ...
user avatar
  • 121
7 votes
1 answer
894 views

How can I generate the same random number in Mathematica and MATLAB?

As a part of my research studies, I have developed a code which is essentially based on random generation of numbers. The first version of the code was written in MATLAB, however, for some reasons I ...
user avatar
  • 1,159
1 vote
1 answer
99 views

How to express number in exponential decimal such as 1e2=100?

I am using MATLAB for a long time, and usually I express the number as exponential decimal such as x = 1e2; % x=100 However, if I write this form in mathematica, ...
user avatar
  • 13
2 votes
1 answer
92 views

Matlab code to Mathemtica, Tensor

I am trying to convert a Matlab code to Mathematica. I have a tensor, RF (a,b,c,d) which is constructed from Hamiltonian (Hs) and 2x2 identity matrix (DS): ...
user avatar
  • 139
0 votes
1 answer
137 views

Implementing an optimization algorithm in WL

I am trying to implement the Jaya optimization algorithm (Jaya). This is a flowchart from the Author 's webpage showing the details of the Algorithm. Note that there is a typo in the equation in the ...
user avatar
1 vote
1 answer
131 views

'quiver' function in MMA (quiver(x,y,u,v))

How to calculate Quiver using the "quiver function" ("Matlab-like")? quiver(x,y,u,v) plots vectors as arrows at the coordinates specified in each corresponding pair of elements in ...
user avatar
  • 1,746
4 votes
2 answers
366 views

'gradient' function in MMA

How to calculate Numerical gradient of 2D arrays using the "gradient function" ("Matlab-like")? "[___] = gradient(F,hx,hy,...,hN) specifies N spacing parameters for the ...
user avatar
  • 1,746
2 votes
1 answer
187 views

Create a matrix without definition of dimensions

is it possible to define a matrix without giving its dimensions in Mathematica, e.g. First line: mattest[[1,2]] = 1; Second line: ...
user avatar
  • 1,746
1 vote
1 answer
186 views

ListContourPlot in Mathematica

I tried to plot the following curves in Mathematica using "ListContourPlot" , and compared them with the results from Matlab 2019a. Mathematica code: (cite from Reference (1)) ...
user avatar
  • 1,746
2 votes
1 answer
236 views

Diagonal matrix command in Mathematica

How to find the corresponding Mathematica commands for diagonal matrix operation in Matlab, e.g. AA=rand(3,3); Step 1.) finding the diagonal elements, and export ...
user avatar
  • 1,746
-3 votes
1 answer
358 views

Need help to convert a Matlab script into a Mathematica script?

I would like to convert a small script but a little technical in Mathematica language. Here is the Matlab script : ...
user avatar
1 vote
0 answers
175 views

Import matlab MAT-format fails

As I did many times before, after updating Mathematica v12.2 I have problem to import matlab *.mat file: I checked ...
user avatar
5 votes
1 answer
113 views

How to determine the file type of a .m file?

Both Mathematica and MATLAB widely uses .m files, but with diametrically different syntaxes and usage. Currently WRI is moving towards the ...
user avatar
  • 658
12 votes
2 answers
540 views

InverseRadon behaves differently from iradon of MATLAB

I have to calculate a 2-dimensional radially symmetric distribution from a single projection. I know that InverseRadon should actually do the job, but I get the ...
user avatar
  • 1,245
3 votes
3 answers
527 views

Changing value of specific element in an array. (Converting code from MATLAB to Mathematica)

Can we change the value of a specific element of an array in Mathematica? Basically, I have the following given MATLAB script which writes a big 3N-by-3N matrix $h$ by combining two 3-by-3 matrices $...
user avatar
0 votes
0 answers
80 views

Is it possible to implement this Matlab code for the normal form of a bipartite operator in Mathematica?

I am interested in converting the $16 \times 16$ ("density") matrix ...
user avatar
1 vote
1 answer
58 views

Create table A with entries of the form Ai_j

I would like to create an $m \times n$-table A with entries Ai_j, where $1 \leq i \leq m$ and $1 \leq j \leq n$. I have seen ...
user avatar
3 votes
1 answer
202 views

Matlab Code and Mathematica Code both identical with different results [closed]

I have spent so much time working around with this code to give the same identical answer as the code I have written before over Matlab. I am just trying to switch towards using Mathematica in my ...
user avatar
  • 67
6 votes
1 answer
337 views

Different results using spline interpolation in Wolfram and MATLAB

I use the same data for interpolation in Mathematica and MATLAB, but the result is different. ...
user avatar
  • 63
0 votes
1 answer
85 views

How to discritize a function domain (break xy-plane to a grid/mesh of squares with vertex values for evaluation)? [closed]

I wrote a code using MATLAB to discritize a function's 2D domain into squares/rectangles, whose vertex data (x,y) I can use to evaluate the function at. Then I sum these values over all vertices to ...
user avatar
1 vote
0 answers
207 views

Mathematica to Matlab (not "so easy" code) [closed]

Based on a Wolfram Demonstration of the Ising ferromagnet using Monte-Carlo Metropolis, I modified it a bit to the anti-ferromagnet case and to get the plot of the order parameters as a function of ...
user avatar
1 vote
0 answers
149 views

Problem in setting up MATlink

I am trying to set up a MATlink using the instructions given here. I get an error while running the following commands Needs["MATLink`"] OpenMATLAB[] Error: <...
user avatar
  • 307
9 votes
1 answer
578 views

Moving B.C.s in heat diffusion model

I came across the paper Solidification dynamics of an impacted drop regarding a heat equations by Thiévenaz et.al and was interested in knowing how they obtained the graphs presented. From what I ...
user avatar
  • 359
0 votes
1 answer
139 views

How can I convert my MATLAB code into WL code?

I am working in MATLAB and want to convert the following snippet into WL code to run on Mathematica. ...
user avatar
  • 101
2 votes
1 answer
56 views

How to import a matrix of integers from MATLAB?

I am importing a matrix from MATLAB. However, there are some redundant items added in the imported matrix. For example, the imported matrix is a binary matrix. After import, it looks like this ...
user avatar
11 votes
1 answer
1k views

Row vectors and column vectors (Mathematica vs. MATLAB)

As far as I know, Mathematica does not distinguish between row vectors and column vectors: all vectors are seen as lists. I know ways to bypass this as suggested in Product between a column vector and ...
user avatar
  • 4,724
6 votes
1 answer
1k views

Frequency Response

How to plot frequency response which includes magnitude response and phase response of a transfer function in Mathematica? In Matlab, we can use [h,k]=freqz(b, a, N); to generate magnitude response ...
user avatar
2 votes
1 answer
399 views

Analog of MATLAB's conv2 in Mathematica?

I have a matlab code filter = 1; F = conv2(double([1 2 1]),double([1 2 1]'))/16; for i=1:some_integer filter = conv2(double(filter),double(F)); end In the ...
user avatar
  • 8,538
5 votes
2 answers
304 views

Simulating ndgrid function of MATLAB

I know that there has been an answer on meshgrid function of MATLAB. For functions involving more than 3 variables, this function does not work. In MATLAB, the ...
user avatar
  • 738
2 votes
0 answers
81 views

How to evaluate expressions in Mathematica from MATLAB?

I found a lot of information and examples on how to communicate from Mathematica to Matlab using MATLink, but nothing for the other way around. I would like to use Matlab to send variables and ...
user avatar
2 votes
2 answers
269 views

Using list of rules from imported .mat file

I'm attempting to learn Mathematica to replace MATLAB. However, I have some data in .mat files which contains named variables. Whenever I import the .mat file, I get a list of rules. What's the best ...
user avatar
5 votes
0 answers
536 views

Is there a way of reading the data out of a MATLAB's ".fig" file in Mathematica?

I have a ".fig" file from MATLAB that I know is a list of $ (x, y) $ coordinates. As far as I know, the ".fig" format stores the data and recreates it every time is opened. I would like to get the ...
user avatar
-1 votes
1 answer
214 views

Native function in Mathematica export functions from Mathematica to MATLAB

Is there any native function in Mathematica (not ToMatlab) that I can export a function from Mathematica to MATLAB, to Paraview or to any plotting software? Clarification: I want to export something ...
user avatar
  • 859
6 votes
1 answer
547 views

An efficient way to translate a triple for-loop from Matlab to Mathematica

This is my first post on StackExchange, so if I violate any etiquettes, I apologize in advance. I am a senior engineering student who has been using Mathematica for a year now. For one of my classes, ...
user avatar
4 votes
2 answers
533 views

Why does NDSolve blow up when given my ODE but bvp4c in Matlab does not?

I am numerically solving the following ODE initially using NDSolve in Mathematica(updated and corrected): $-(-\frac{z'(r)}{r \sqrt{z'(r)^2+1}}-\frac{z''(r)}{\left(z'(r)^2+1\right)^{3/2}})=A_1(z(r)+H)...
user avatar
  • 41
2 votes
1 answer
236 views

Multidimensional MATLAB conversion

I try to convert this MATLAB code: From: https://github.com/gpeyre/2013-SIIMS-ot-splitting/blob/master/code/toolbox/%40staggered/interp.m https://github.com/gpeyre/2013-SIIMS-ot-splitting/blob/master/...
user avatar
  • 145
5 votes
3 answers
1k views

Surface plot for matrices (Matlab-Mathematica)

Now I am try to convert matlab file to mathematica, This is the original Matlab command, surf, for making surface plots: ...
user avatar
  • 1,746
1 vote
1 answer
90 views

Drawing a surface using an Excel file

I’m totally new to Mathlab. I have the following ‘grid data’ to be read from ‘Office Excel’ that I need them to be drawn as a surface in the Mathematica or Mathlab. I’ve done this with the ‘Surface’ ...
user avatar
  • 293
0 votes
0 answers
270 views

How to automatically load the ToMatlab toolbox when opening the software? [duplicate]

I would like to convert the formula to Matlab, but each time I want to run the ToMatlab file, is there any way to automatically load the ToMatlab component when launching the software?
user avatar
  • 65
1 vote
1 answer
342 views

Convert MATLAB Code to Mathematica

I have written a MATLAB code as following, in order to calculate an integration involving Modified Bessel Function with variable limits: ...
user avatar
0 votes
1 answer
224 views

How can I get rid of extraneous brackets when importing data from MATLAB? [closed]

How can I easily correct this data sequence from MATLAB to one readable in Wolfram Mathematica? The problem is the 2 outer brackets: ({{ ... }}) ...
user avatar
  • 65
2 votes
0 answers
107 views

Missing data - reconstructing large gaps with an autoregressive model

I am looking for a similar function as fillgaps in Matlab which helps to "replace missing samples in an otherwise uniformly sampled signal by fitting an autoregressive model to the samples surrounding ...
user avatar
  • 347
2 votes
0 answers
114 views

How to call a Matlab user-created function in a .m file from Mathematica?

I have a file called gensys.m where it's defined a function gensys, which I would like to call in the mathematica environment and work with it. I've tried to ...
user avatar
1 vote
1 answer
146 views

What's the best reference for learning how to best use both Mathematica and MATLAB? [duplicate]

I'm pretty good at using MATLAB for a lot of different things, and less familiar with Mathematica, but I just got accepted to a graduate school in mathematics where (from what I can tell so far) some ...
user avatar
  • 11
5 votes
0 answers
190 views

How to efficiently apply PCA followed by SVD to extract the components of PCA?

I am working on segmenting a textured image using Gabor Filters. This is based on this paper. There exist a Matlab implementation of this as well. Earlier I managed to do up to this. With the help of ...
user avatar
  • 3,113