Questions tagged [matlab]

DO NOT use both the [matlab] and [octave] tags unless the question is explicitly about the similarities or differences between the two. MATLAB is the high-level language and interactive programming environment for numerical computation and visualization developed by MathWorks. When using this tag, please mention the MATLAB release you're working with (e.g. R2017a).

matlab
Filter by
Sorted by
Tagged with
0 votes
0 answers
3 views

find all the separated regions shown in the right figure, and calculate the area of each of them

I have the matlab code of using gauss random field equation, which generates two-phase composites, and I can get the boundary of it. I want to find all the separated regions, shown in the black and ...
0 votes
0 answers
10 views

I encountered an error message stating "Inconsistent row/column dimensions" when using the leastsq command

I'm looking to perform parameter estimation for a system of nonlinear differential equations using the provided data in the ym matrix for y1, y2, and y3. After that, I aim to fit this data with the ...
0 votes
0 answers
17 views

Implementation of MATLAB function in c#

I wrote a function as follows in MATLAB: function [z] = zarb(a, b) z = a * b; end I fixed this code with "dll" and added it in "Add References". And I used it with the following ...
-2 votes
0 answers
21 views

What are the steps we can follow to integrate .m/.mat file to integrate it with our cpp Project in Visual Studio? [closed]

I am working on Chai3d library for Haptic Rendering so i have to feed it data which is defined through a MATLAB(.m) file so need to include it in my project. Please provide references as well if you ...
-1 votes
0 answers
10 views

This program performs a simulation of a non-linear least squares problem using the Gauss-Newton algorithm

this is my code for simulation for a non linear least squar model using gauss milton i tired with the gradient but now olso dosn't work what do you think i should do % Simulation N = 4:10:1000 ; ...
0 votes
0 answers
17 views

How to run python script that uses pytorch from matlab?

I have a deep learning python module which I would like to call from a matlab program. I tried using pyrunfile() but I get: Python Error: RuntimeError: DataLoader worker (pid(s) 12136, 18172) exited ...
0 votes
0 answers
9 views

solving powell badly scaled test function using conjugate gradient method

I am trying to solve the powell bad scaled test function, which and its gradient function are given below: function f = fun(X) x = X(1); y = X(2); f1 = 1e4 * x * y - 1; f2 = exp(-x) + ...
0 votes
0 answers
14 views

how to pad audioDataStore files to be same length?

I am writing a project that will do a knn of speech emotion dataset to test accuracy. the problem im having currently is my files are all different lengths so if i try to concatenate my features to ...
0 votes
0 answers
8 views

How to plot reflected trajectory inside a rectangle in MATLAB?

I wrote a function caterpillar that takes arrays of x and y values and plots several circles following the line described by the coordinates. Next I need to write a function that will make the ...
5 votes
3 answers
2k views

SLURM: Embarrassingly parallel program inside an embarrassingly parallel program

I have a complex model written in Matlab. The model was not written by us and is best thought of as a "black box" i.e. in order to fix the relevant problems from the inside would require rewritting ...
0 votes
0 answers
8 views

Is it possible to call Flask based server-side api in Simulink

I looked up how to integrate Python with Simulink (see link), however this is for an actual algorithm. What I'm trying to achieve is create a Matlab function or system (class) that calls Python rest ...
0 votes
0 answers
10 views

Matlab/Arduino: Unsuccessful read: A timeout occurred before the Terminator was reached

i get the following error, when i'm running my code: Warning: Unsuccessful read: A timeout occurred before the Terminator was reached. 'serial' unable to read any data. For more information on ...
0 votes
1 answer
26 views

How to generate animations automatically in Live Editor

I am using MATLAB R2024a,editing in live editor, and update a plot in while loop, how to animate the update progress automatically? Here is my sample code, updating a plot in the while loop. When n is ...
0 votes
0 answers
24 views

Starting point in MPC controller - y(i)

I wrote a MATLAB code for MPC for controlling room temperature. and set the setpoint on 25 degree, while the start point is 20 degree. But in simulation the start point (20 degree) is deceased to zero ...
0 votes
1 answer
2k views

matlab switch complex and real parts of a number

I have a column list of complex numbers (about 200k long). I want to switch all the real and imaginary parts. I'm pretty sure there is a single multiplication I can do to accomplish this, but I can'...
0 votes
0 answers
16 views

how to get a prediction output sequence of NARX model by MPC

two question: now there are a NARX model: y(t)=y(y(t-1),y(t-2),u1(t-5),u1(t-6),u2(t-5),u2(t-6)), i have trained my network offline for identifing the plant, and the output of network is prediction ...
0 votes
0 answers
13 views

Can you recommend me some good books for sensor data fusion algorithms (Kalman filter for instance) theory and applications? [closed]

I want a based documentation on sensor data fusion theory and applications and some tutorials, please. Ive tried some tutorials from Matlab Mathworks, but I dont seem to get how to apply fusion ...
1 vote
1 answer
14 views

matlab script control over code in simulink matlab function block

I want to write a matlab script that creates a matlab function block in simulink and then writes the code into the block. Or, some equivalent of this. I can create the block using add_block(), and I ...
-1 votes
0 answers
21 views

Lagrange and Newton interpolation

I am wondering if Lagrange and Newton interpolation give very close results. Becouse i did both of them in matlab. I calculated the average and maximum interpolation error and they were the same, i ...
0 votes
0 answers
17 views

How to edit nodal coordinates of abaqus input file to create identical mesh

I am trying to create an identical mesh on the opposite faces of my geometry (a cuboid with some partitional surface features), so I made three node sets on three faces. I have meshed the model. In ...
-1 votes
0 answers
26 views

Why is my MatLab Interpolation giving me an error message? [closed]

I used the function interp1 in some code I wrote. The first time I ran the entire script, the code ran fine, but when I went to run it again after I wrote in a bunch of if statements, it ran an error ...
0 votes
0 answers
17 views

Error loading images programmatically in Medical Image Labeler (MATLAB)

I'm trying to upload a series of nifti images in a new session of Medical Image Labeler. I created a groundTruthMedical object copying the structure of the groundTruthMedical object that the app ...
1 vote
1 answer
32 views

R equivalent of MATLAB's pascal(n, 1) different column signs

I'm porting some MATLAB code to R and have come across this function: pascal(4, 1) which, according to the documentation, "returns the lower triangular Cholesky factor (up to the signs of the ...
0 votes
1 answer
33 views

Reading from MAT files(or similarly from other options) to CUDA/C

For a project I need sparse matrices retrieved from this website: https://www.cise.ufl.edu/research/sparse/matrices/list_by_id.html Where matrices are in the form of .MAT and other formats which I am ...
0 votes
0 answers
16 views

Solve Nonlinear ODE Symbolically MATLAB

I have the following nonlinear ODE: I have the following ODE45 solution: fun = @(t,X)odefun(X,K,C,M,F(t),resSize); [t_ode,X_answer] = ode45(fun,tspan,X_0); The input matrices are stiffness K(X(t)),...
2 votes
1 answer
26 views

Simulink/Matlab, what is the name of this block?

Here is a image I highlighted it with a red border. I'm counting on your help, because I couldn't find it in MATLAB's documentation myself. The author in the recording also doesn't mention what this ...
0 votes
1 answer
57 views

Matlab Path optimization algorithm for long subpaths search and small subpaths minimization

I am developing a code to find the best subpaths in a complex graph. My graph is just a representation of a physical structure, so my edges are actual segments. When I say "best" I want to ...
0 votes
0 answers
11 views

Unzipping MDF4 files and combining them into 1

I am trying unzip a collection of mdf4 files, combine them into 1 mdf4 file and save it. I am getting the following error: Invalid argument at position 2. Value must be one of the following types: '...
0 votes
0 answers
17 views

2 phase simplex method works incorrectly

I need to write solution for 2 phase Simplex method. I made solution, but I'm not sure that it works correctly and sometimes answers are not correct. For example, my code gives me solution: 0 0 0....
0 votes
0 answers
20 views

Update the Kalman Filter in Simulink model

I want to creat a Filter in Simulink. For example: filter = trackingKF('MotionModel', '2D Constant Acceleration', 'State', zeros(6, 1)); Then in simulink model, I want to update the filter and ...
0 votes
0 answers
13 views

Is there damping in the mechanical translational converter (G) in Simulink? [closed]

I'm trying to simulate a Free Piston Stirling Engine. In course of that, I am trying to understand the translational mechanical converter (TMC), which translates gas pressure into mechanical force and ...
2 votes
1 answer
534 views

Matlab 'bridge' 'shrink' and 'holes' equivalent morphological operations in openCV

I am trying to bridge unconnected pixels in an image using opencv-python. In matlab there is bmmorph function which takes in 'bridge' operation which does this. I am trying to do similar thing using ...
4 votes
3 answers
6k views

MATLAB: 3d reconstruction using eight point algorithm

I am trying to achieve 3d reconstruction from 2 images. Steps I followed are, 1. Found corresponding points between 2 images using SURF. 2. Implemented eight point algo to find "Fundamental matrix" 3....
-1 votes
0 answers
19 views

2D to 3D Image Reconstruction using MATLAB [closed]

Title - 2D to 3D Image Reconstruction using Eight Point Algorithm in Matlab. Question - Can anyone provide me with the MATLAB code for the achieving the outputs given in the links below:- Hints:- ...
-1 votes
0 answers
25 views

How can I connect Matlab to my Github account?

I cloned and modified the content of my github repository on my mac, and I am just wondering how to push the modified files back into my github repo again. On matlab's command window, I ran: >>!...
0 votes
1 answer
31 views

How to slice a 3D cylinder in MATLAB?

I'm trying to create a function that plots a cylinder with slices at a given angle where: l - length of a cylinder d - diameter a - angle n - number of slices Here is what I have so far: function ...
-1 votes
1 answer
75 views

What do offset and drift represent in an fMRI signal? [closed]

I found an MVPA for brain fMRI toolbox online. There is one thing I cannot understand. The toolbox uses: X = [ones(numTimeStampPerRun,1) [1:numTimeStampPerRun]']; % account for both offset and drift ...
4 votes
3 answers
2k views

Good way to view matrices and higher dimensional arrays in VScode

When working with PyTorch/numpy and similar packages, is there a good way to view matrices (or, in general, arrays with two or more dimensions) in debug mode, similar to the way Matlab (or even ...
-1 votes
0 answers
12 views

Bayesian estimation and traditional with matlab

Assume that you receive 1000 - 10,000 · (θ∗ - θ)2 SEK if you estimate θ with θ∗. If you guess exactly right, you receive 1000 SEK, while for example you only receive 375 SEK if θ = 0.5 and your guess ...
0 votes
0 answers
7 views

Identify PID Parameter for a nonlinear Simulink System without an objective function

For a huge nonlinear Simulink system, I have to find optimal PID Parameter. It isn't possible to build the objective or the fitness function. Do you know a alogirthm to identify optimal PID Parameter ...
-1 votes
0 answers
18 views

Identify PID Parameter for a NONlinear System without an objective function [closed]

My task is to find optimal Parameter(PID) but I have a huge Simulink System(nonlinear) and cannot build an objective function or a fitness function. Because of that I cannot implement Genetic ...
63 votes
8 answers
56k views

Parfor for Python

I am looking for a definitive answer to MATLAB's parfor for Python (Scipy, Numpy). Is there a solution similar to parfor? If not, what is the complication for creating one? UPDATE: Here is a typical ...
-1 votes
0 answers
11 views

vanishing gradients of combined neural networks [closed]

I implemented a neural network in MATLAB which consists of sub-networks. But the error doesn't decrease and the values of deltas are very low. I think it stuck in a local minimum or vanishing ...
0 votes
0 answers
8 views

Reset Functions for Reinforcement Learning in Matlab

So im attempting to build a Reinforcement Learning AI in Matlab to train a controller for a system. The issue I'm running into is with the reset function that allows some of the initial parameters of ...
0 votes
1 answer
47 views

Is min(A,[],"all") or min(A(:)) more efficient?

In matlab, which is more efficient, min(A,[],"all") or min(A(:))? A is a 200x200 matrix. My first idea is that min(A,[],"all") should be faster. Because A(:) will expand the matrix....
1 vote
1 answer
124 views

How to make smooth curve nerve signals from neuron spike data

I have my data stored in structures regarding recording from neurons. Neuronal spikes are stored in a logical array where a spike is 1 and no spike is 0. spike = <1x50 logical> spike = [1 0 0 ...
0 votes
1 answer
460 views

Creating a 3D wireframe cortical model from MNI brain template with Matlab using MyRobustCrust

I am attempting to create a wireframe 3d model from an MNI brain template using MyRobustCrust on matlab. My goal is to be able to determine MNI coordinates on the cortical surface. To do this, I'm ...
-2 votes
0 answers
15 views

Density Functional Theory matlab program for helium atom [closed]

I am doing some studies from the book "Computational Physics by Thijssen", and I found a matlab code for LDA-Helium atom to see how the instructions applied but I need some help in ...
0 votes
1 answer
18 views

transferring data between python and MATLAB: how to deal with list of lists?

I did this post in Mathwork as well. But I guess I will benefit also asking it here. Here is a link to my mathwork community post. https://www.mathworks.com/matlabcentral/answers/2104821-load-save-...
0 votes
0 answers
37 views

Segmenting all contours or a better approach for these pellets

I am attempting to find the governing equation for the Position(x,y,t) and Orientation θ(x,y,t) of these pellets, which collectively behave as a fluid. To perform flow analysis and find governing ...

1
2 3 4 5
1899