0
votes
1answer
13 views

Converting a Matlab fft2 diffraction example into Python

I trying to teach myself some FFT basics using python. At the moment I'm trying to reproduce a matlab FFT2 diffraction result using python and associated libraries. The example I'm trying to simulate ...
1
vote
2answers
39 views

Equivalent of “genvarname” in Python

How can I generate a variable name from a string (say a concatenation of a letter and a number) ? In Matlab, this task can be easily done using genvarname
3
votes
2answers
55 views

Is there a simpler way to construct Mandelbrot set in Matlab?

The code shown below for drawing a Mandelbrot set, I think my code a bit redundancy to construction the Matrix M. In Python I know there is a clean way do this, M = [[mandel(complex(r, i)) for r in ...
1
vote
2answers
71 views

Introduction to Debugging Compiled Languages for MATLAB Users

I've used MATLAB for ages and am quite proficient. I'm used to MATLAB debugging where you can skip lines and see the variables and how they change, and that's how I learned to code. I'm now looking at ...
1
vote
2answers
42 views

Merge excecution logs into a report

I insert some strobes into a C source code in order to obtain interesting information about every execution. At the moment i print the information in a file at every execution. I have this kind of ...
2
votes
3answers
95 views

Speed for filling a matrix in python vs matlab

I am testing the speed of Python in comparison with Matlab. I decided to move to Python because of the many advantages it has but I wanted to compare the speed to see what is the difference in this ...
1
vote
1answer
54 views

Redirect filepointer to string in C/C++

MATLAB allows saving variables to files via a closed-source library, that e.g. exposes the following functions: FILE *matGetFp(MATFile *mfp); MATFile *matOpen(const char *filename, const char *mode); ...
6
votes
1answer
65 views

Can I arrange 3 equally sized subplots in a triangular shape?

To make this clear, I will use an 4x4 grid to show where and how large I want my subplots. The counting goes like this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 I want the top plot to be ...
1
vote
1answer
37 views

Python - How to know if Matlab is complaining about missing free network license

One of the tools I use at work is Matlab, however due to server license there is limited number of users that can use it at the same time. I decided to write a short script that will open Matlab - ...
1
vote
0answers
73 views

What are the differences between iterators in different languages ? [closed]

I am doing a research on iterators but i am pretty much confused about What are the main differences between the iterators of the different languages like Python, PHP, Matlab, C# in terms of ...
1
vote
2answers
51 views

'Safe' Assignment in MATLAB [duplicate]

I've noticed that in a python code you can do something like: a=0 b=1 a,b=b,a print(a,b) which outputs (a=1,b=0) (i.e. each variable is assigned independently of the last assignment). Is there a ...
0
votes
1answer
71 views

Running MATLAB from Python

I'm teaching myself a little bit of programming in python and also matlab. And I need to run a couple of functions I wrote in python with matlab. I've followed the basic install instructions for ...
-1
votes
0answers
43 views

Matlab function grpstats with Python (efficient way)

Is there an efficient way to perform the same computations as Matlab's grpstats with Python? I have been reading the documentation about the pandas library, but I cannot find anything that does ...
3
votes
0answers
53 views

Scipy LinearOperator With Multiple Inputs

I need to invert a large, dense matrix which I hoped to use Scipy's gmres to do. Fortunately, the dense matrix A follows a pattern and I do not need to store the matrix in memory. The LinearOperator ...
1
vote
0answers
34 views

Solving ODE in complex domain with Python (or Matlab)

As a test for a more complicated system, I want to solve a differential equation dw/dz = w where the function w = w(z) is complex valued and z = x+iy as usual. The boundary conditions are w = i when z ...
1
vote
1answer
37 views

Matlab output format that Python can consume

I am pretty new to Matlab but relatively familiar with Python. I am now using an existing Matlab code but I want the the program to generate output that Python can consume. The standard output format, ...
0
votes
1answer
70 views

Dynamic programming in Python

I have been trying for a couple of days to implement a simple program from a Matlab code to Python. I am using numpy but if there is a better way I am open to it. This is my Matlab code: ...
0
votes
0answers
30 views

Searching a function in Matlab that fits to python function “ndimage.map_coordinates”

I'm trying convert a code from python to matlab. It worked so far... until I came to this python function: ndimage.map_coordinates(inputarray, [x,y], output=output) I'm searching for a corresponding ...
0
votes
1answer
50 views

How do you get “matlab style” function output in python

My question is specific to the first line in a matlab function function [a, b, c, d] = somefunction(arg1, arg2, arg3) % Some mangoes and pears end specifically to the left hand side of that ...
1
vote
2answers
61 views

Python equivalent of MATLAB command prod

Is there a python equivalent of the MATLAB command "prod" (described here)?
0
votes
0answers
48 views

Fast Connected Component Labeling in Python

I am trying to identify connected regions of pixels in an image stack. Since it is a stack, the input is quite large (on the order of 10 million pixels, although only about 1 million are bright), and ...
1
vote
2answers
91 views

Complex eigenvectors of a symmetric matrix in MATLAB

I am facing an issue when using MATLAB eig function to compute the eigenvalues and eigenvectors of a symmetric matrix. The matrix D is 10x10 all diagonal elements = 0.45 all off-diagonal elements ...
1
vote
4answers
97 views

Can we draw digital waveform graph with Pyplot in python or Matlab?

I am trying to draw digital signal waveform graph for bits like 01010101010101 using pyplot in python, like Is it possible with Pyplot?
0
votes
1answer
63 views

Cannot open matlab files using the latest HDF5

I recently upgrade tables on my python installation and some strange things seem to be happening with the HDF5 libraries. I've got a bunch of data that was originally saved as a .mat file, which ...
2
votes
2answers
68 views

Numpy and Matlab difference in sum?

I have a code that I am trying to translate from Matlab to Python however there is a problem with summation: a=np.arange(1,28).reshape(3,3,3) print a print np.sum(np.sum(a,axis=1),axis=2) gives me ...
5
votes
1answer
93 views

Converting matlab code to python

Okay so I have a datafile from an EEG scan (a binary file, data.eeg), and in matlab the code to read the file and plot a section of the data goes like this: sr=400; ...
1
vote
0answers
50 views

image reconstruction from parts [closed]

I am having trouble with some image processing and need help. The problem I need to solve is: I am given n (n=2,3,4) images of a painting but each image is only a part of the painting. I need to ...
0
votes
1answer
56 views

Matlab to Python Stat Equation

I was wondering if anybody could help me translate the following code from MatLab into Python. The equation is used for determining the 99% Confidence Interval of a truncated normal distribution. ...
6
votes
3answers
132 views

Use of eval in Python, Matlab, Etc [duplicate]

I do know that one shouldn't use eval. For all the obvious reasons (performance and maintainability, etc.). My question is more on the side – is there a legitimate use for it? Where one should use it ...
0
votes
0answers
75 views

Mechanical Linkage Optimization Algorithm

I am trying to find an algorithm that can optimize the lengths of a mechanical linkage, such as a simple four-bar linkage, to provide the longest stride length possible. I am aware of a project that ...
-1
votes
0answers
54 views

Why is urlread in MATLAB sometimes very slow?

When upgrading MATLAB from 2010b to 2012b, the function urlread slowed one of my test programs from a couple seconds to over 5 minutes. I use a web-service architecture to solve mathematical ...
3
votes
1answer
81 views

a simple, matlab-like way of finding the null space of a small matrix in numpy (and number formatting)

There must be a simple way to get a null space of a small (say 3x3) matrix in python's numpy or scipy. MATLAB can be good about this. Let's say: A = [1 2 3; 2 3 4; 2 4 6] rank(A) % rank ...
2
votes
1answer
49 views

Turning a python ndarray into a matlab file

So I have an CSV file that I have read into a list. I have turned that list into an array, and have saved the array into a MATLAB file with the following function. def save_array(arr,filename): ...
3
votes
1answer
68 views

creating Matlab cell arrays in python

I'm trying to create a Matlab cell array in python and save it as a .mat file, but am running into problems when all the cells contain 2 values: import scipy.io as sio twoValues = {'a': ...
0
votes
0answers
48 views

Draggable rectangle in matplotlib

Is there a simple way to implement a draggable rectangle in a matplotlib plot that acts like Matlab's "imrect" function. A very similar question was asked previously, but the result obtained there ...
8
votes
2answers
150 views

What is most efficient way of setting row to zeros for a sparse scipy matrix?

I'm trying to convert the following MATLAB code to Python and am having trouble finding a solution that works in any reasonable amount of time. M = diag(sum(a)) - a; where = vertcat(in, out); ...
2
votes
2answers
104 views

matlab syntax of “ ' ”

I am trying to convert some matlab code into Python. I have almost no experience with matlab, but I just need to borrow a little functionality. I am stuck on this part: In this example, V is a 3x3 ...
0
votes
1answer
47 views

Does Matlab's fminimax apply Pareto optimality?

I am working on multi-objective optimization in Matlab, and am using the fiminimax in the Optimization toolbox. I want to know if fminimax applies Pareto optimization, and if not, why? Also, can you ...
3
votes
1answer
64 views

face warping / morphing - no framework around?

I've been searching for quite a while and haven't found a real answer, yet, maybe I've got tomatoes on my eyes, but is there really no framework around for python / MATLAB which does a face warp / ...
-1
votes
2answers
89 views

Run Python file from matlab .m file

I am looking to run a file I created in python from a matlab script. I have checked that my python file works if I run it from the python interface. However I have not been able to get my python to ...
1
vote
1answer
23 views

Do python have a Matlab's ans kind of variable that captures not equalized to any variable?

If you are familiar with Matlab, there is a global variable ans that captures the first return value of a function that is not assigned to any particular variable. Is there any matching construct in ...
2
votes
2answers
74 views

Python/Numpy: How do you assign the end+1 element of an array similar to how it's done in Matlab?

For example, for a 1D array with n elements, if I want to do this in Matlab I can do: A(end+1) = 1 that assigns the value of 1 to the last element of array A which is now n+1 in length. Is there an ...
2
votes
3answers
46 views

Concatenate 3 unidimensional arrays together in numpy

I'm leaving MatLab for numpy and in general it's going ok, but I'm having a nightmare finding a nice pythonic way to do what would have done this in MatLab: A=[1.0;2.0;3.0;4.0] %Column vector ...
0
votes
2answers
47 views

Finding specific values and replacing them by others. Python

I am very new to programming. I have code in matlab: x2(x2>=0)=1; x2(x2<0)=-1; %Find values in x2 which are less than 0 and replace them with -1, %where x2 is an array like ...
0
votes
1answer
18 views

Multiple outputs with mlabwrap

I have a Matlab function that returns a variable number of results. In Matlab I call it in the following way >> [A, B] = func(C); When I use mlab to wrap this call in Python I only get A ...
1
vote
1answer
75 views

Python analog to MatLab data structure

I've recently jumped out of the matrix laboratory window and I'm trying to get Python/Numpy/Scipy to do the things I used to do in MatLab. It seems really good so far, but one thing I'm struggling ...
1
vote
0answers
77 views

Color matplotlib quiver field according to magnitude and direction

I'm attempting to achieve the same behavior as this function in Matlab, whereby the color of each arrow corresponds to both its magnitude and direction, essentially drawing its color from a wheel. I ...
2
votes
1answer
173 views

Finding the Distance Between Two Lines that represent GPS routes (MATLAB, Java, C++, or Python)

I have been researching and trying to figure this one out to no avail. I have found many ways not to solve this... The gist of the problem: I am looking for a method to calculate the deviance from an ...
0
votes
1answer
46 views

Using matlab's find like operation in python

I have this matrix of shape 10,000x30 in python. What I want is to find the indices of the rows, i.e., from the 10,000 rows, determine the indices with the 5th column value equal to 0. How can I get ...
0
votes
0answers
103 views

HMM with continuous emissions

I have d observations whose state emission probabilities I want to model using a d-dimensional Gaussian mixture density. Initially, I want to use existing software solutions. What is the Matlab way ...

15 30 50 per page