Questions tagged [matlab]

Please refrain from combining both the [matlab] and [octave] tags unless the inquiry specifically pertains to comparing the two. MATLAB, created by MathWorks, is a sophisticated language and programming environment designed for numerical computation and visualization. When utilizing this tag, kindly specify the version of MATLAB you are using (e.g. R2017a).

What are the steps to implement OpenCV for a real-time application?

When it comes to real time systems, a quick and efficient platform is essential. I'm curious about which combination would be best for real time image processing: OpenCV-Python, OpenCV-MVStudio (C++), OpenCV-Matlab, or OpenCV-Java? I've heard abo ...

Converting HDF5 data from MATLAB to a Pandas DataFrame using Python

I am facing an issue while trying to load .mat files with HDF5 data into Python as a Pandas DataFrame. Here is my current code: f2 = h5py.File("file.mat") f2['data'] Upon running this, I get the following output: <HDF5 dataset "data": shape ...

How can I transform a multidimensional dictionary into a JSON file?

I have successfully imported a *.mat file containing a 'struct' into my jupyter lab using the following code: from pymatreader import read_mat data = read_mat(mat_file) As a result, I now have a multi-dimensional dictionary structure as shown be ...

Capturing the result of a MATLAB function in Python: A Comprehensive Guide

I have a piece of python code that calculates the mean of an array using the following script: def calculate_mean(array): p = os.popen('matlab -nodesktop -nosplash -r "mean('+str(array)+');exit"') while 1: line = p.readline() if n ...

Calculate the covariance matrix using Numpy with the built-in function `numpy.c

I have been working with numpy and am attempting to calculate the covariance matrix for an ndarray. Despite my efforts using numpy.cov(), I am experiencing issues with the results not matching what I expect. Here are more details: The shape of my ndarray ...

Transforming MATLAB script into Python

As a newcomer to Python, I am struggling with vectorized operations and indexing in Python. While I can easily rewrite it in C-style for element-by-element calculation, I want the Python code to be more "pythonic" and concise like MATLAB. I aim for brevity ...

Try implementing the functionality of MATLAB using Python code, or look for a comparable alternative

I have a project where I need to translate Matlab code into Python, but not at a very low level. The issue I'm facing is that I have the following lines of Matlab code: p = sobolset(problem_size, 'Skip', 1e4, 'Leap', 1e3); p = scramble(p, 'MatousekAffineOw ...

Translating data between Python and MATLAB by decoding binary files

I am encountering a significant issue with the struct.unpack function in Python. I have a binary file that follows a specific format, which can be written either in MATLAB or Python. When I write data to a binary file in Python and read it back, everythin ...

Can different types of code be safely stored together within a single git repository?

In the process of launching a new project, my team and I are faced with the challenge of determining how to best organize our code in Bitbucket. None of us have experience working at software development companies, but we all possess technical knowledge. T ...

Executing multiple m-files in batch on Windows OS without the need to close any previously opened m-file

My goal is to efficiently execute a sequence of m-files and Python programs. Thanks to the contributions of Mofi, Shai, and moarningsun, I have successfully implemented this batch file on my Windows operating system: start "01" /wait "C:\Program Fil ...

Leveraging numpy arrays for handling both integer values and arrays as input

As a Matlab user transitioning into Python, I attempted to code a minimal version of the de2bi function in Python. This function converts a decimal number into binary with the right-most significant bit first. However, I encountered some confusion when wor ...

Error when using Python's scipy.optimize fmin instead of Matlab's fminsearch function

I'm currently working on translating a matlab function handle to python and encountering the error message (ValueError: setting an array element with a sequence) in my python script. As I am still new to python, I apologize if there is an obvious mistake i ...

Simulink does not allow referencing Matlab cell data

When I try to call a python function from Matlab that returns a list, I am able to successfully load those values into an array and see the expected results in the CommandWindow: >> myList = cell(py.myPyModule.myPyFunction()); >> disp(myList); ...

Guide to programmatically importing a JSON file into MATLAB?

I need help loading data from a JSON file into MATLAB with comma delimiters. The data format looks like this: {"created_at": "Mon Oct 27 20:35:47 +0000 2014", "tweet": "Silver Finished Up, Gold, Copper, Crude Oil, Nat Gas Down - Live Trading News http://t ...

Using MATLAB's jsonLab for parsing a JSON data structure

I am facing an issue while trying to parse a JSON object into a cell array in MATLAB. The error I encounter when parsing the filename is... `Error using loadjson>error_pos (line 431) JSONparser:invalidFormat: String starting with " expected at position 18 ...

Import information from a website into MATLAB, including embedded internal frames (iframes)

Recently, I've been using MATLAB's urlread function to fetch website content for further analysis. However, I encountered a specific site where the data I'm looking for is housed within an internal frame embedded in the main index.php file ...

Methods for converting camera calibration parameters stored in a .mat file from Matlab into numpy arrays in Python

After successfully calibrating the camera using Matlab 2019a, I saved all the camera parameters in a variable called cameraParams. However, I am specifically interested in extracting the Intrinsic matrix and distortion coefficients from this data. How c ...

Error encountered while parsing JSON file: 'additional text' is causing a syntax issue

I am attempting to retrieve data from a JSON file on an Arduino board using MATLAB with the script below: fileName = 'test1.json'; % specify the filename with a JSON extension str = fileread(fileName); % read the file as text data = ...