Skip to main content

All Questions

Tagged with
2 votes
1 answer
59 views

Create a similar matrix object in matlab and python

For comparison purposes, I want to create an object which would have the same shape and indexing properties in matlab and python (numpy). Let's say that on the matlab side the object would be : ...
servoz's user avatar
  • 657
52 votes
5 answers
25k views

numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

I want to call my Python module from the Matlab. I received the error: Error using numpy_ops>init thinc.backends.numpy_ops Python Error: ValueError: numpy.dtype size changed, may indicate binary ...
Encipher's user avatar
  • 1,972
1 vote
1 answer
53 views

Matching numpy rand ndarrays with MATLAB

I'm trying to match randomly generated ndarrays from numpy with MATLAB. import numpy as np # Set the seed for NumPy's random generator np.random.seed(42) #Mersenne Twister is default # Generate ...
Naveen's user avatar
  • 469
1 vote
1 answer
68 views

How to pass large arrays of data from MATLAB to Python

My data is stored in classes in MATLAB which contain large arrays but want to work with that data in python for training machine learning. From what I can tell, when moving data between the two, the ...
Leon Williams's user avatar
0 votes
1 answer
92 views

How to use arrays in Python similar to how they're used in matlab

I'm currently trying to improve my python skills by using it to recreate some old matlab projects I did in undergrad. I once used matlab to simulate a proton attracting an electron, using ...
Hector Viruega's user avatar
0 votes
0 answers
56 views

Matlab Versus Python - Interpolation Errors with Matlab "scatteredInterpolant" versus Python's "Griddata" from scipy.interpolate

I'm currently trying to convert some Matlab code into Python. I'm running into an error that I suspect has to do with rounding, but am unsure about what is causing it. Matlab: deg2rad = pi/180; % ...
Sweet Zhang's user avatar
2 votes
2 answers
282 views

How is a 3D/4D array stored with column-major order contiguously in memory?

While I have no trouble understanding 2-dimensional arrays, I want to know how precisely MATLAB (or modified NumPy) stores higher-dimensional arrays in memory. To avoid abstract answers, I ask my ...
Ardy's user avatar
  • 15
1 vote
1 answer
113 views

Mismatch between Matlab log and Numpy np.log

While rewriting an old Matlab code to NumPy, I noticed differences in logarithmic calculation. In NumPy, I use np.log, Matlab uses log function. b = [1 1 2 3 5 1 1]; p = b ./ sum(b); sprintf('log(%....
Martin Benes's user avatar
0 votes
0 answers
68 views

Numpy ndArray is not flattening with flatten()

I have a numpy ndArray which is of shape (500,20,8) of float64. Keep in mind however that when I get the shape of such array, I get the following output. I do not know if this is OK: mat = sp.loadmat('...
akaBryan's user avatar
  • 102
0 votes
0 answers
67 views

Signs of Matlab and Numpy Graph Fourier Transform Matrix are Different

I would like to ask why I see the same numerical results but with different signs for the same demo data. I understand that the signs are arbitrary, but I'm using the transpose of this matrix in later ...
Michael Paglia's user avatar
-1 votes
1 answer
163 views

Is there a Python equivalent of Matlab's potential(V, X, Y) function

Is there a library in python that provides the same functionality as Matlab's potential(V,X) function, which inverts a 3D or 2D gradient into a scalar potential surface? I've tried a couple of brute-...
Bill Capehart's user avatar
0 votes
0 answers
98 views

Converting derivative block of Simulink into a python code

I have a Simulink model and I want to translate the whole model to a python code. Now I am struggling with the translation of a block named "derivative". The documentation regarding this ...
Soheil yns's user avatar
3 votes
1 answer
109 views

Recreate randperm Matlab function in Python

I have searched on stackoverflow for people facing similar issues and this topic Replicating MATLAB's `randperm` in NumPy is the most similar. However, although it is possible to recreate the ...
Paul Ledesma's user avatar
2 votes
1 answer
98 views

Sums of random number reorderings combine to recurring values

g0 = randn(1, 100); g1 = g0; g1(2:end) = flip(g1(2:end)); sprintf("%.15e", sum(g0) - sum(g1)) g0 = np.random.randn(100) g1 = g0.copy() g1[1:] = g1[1:][::-1] print(sum(g0) - sum(g1)) In ...
OverLordGoldDragon's user avatar
1 vote
0 answers
95 views

Different matrix multiplication result in MATLAB and Python leads different eigenvectors

I am trying to convert my MATLAB code to Python. I have to multiply two matrices and calculate the eigenvector and eigenvalues of the multiplication result. Here are the two matrices P = [0....
galib's user avatar
  • 103

15 30 50 per page
1
2 3 4 5
72