Questions tagged [matlab]

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

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

Using global optimization Matlab toolbox and genetic algorithm to minimize black-box function

I have following objective function: function w = objective_function(a,b,c,d) rh = @(t,y) [y(2); - a*y(1) - b*(1-y(1)^2)*y(2)]; [t,y] = ode45(rh,[0,10],[c;d]); u = 2*exp(-0....
azonips's user avatar
  • 13
-1 votes
0 answers
11 views

calculate a vector of channal estimation error in cell free Massive MIMO with centralized zero forcing precoding

how can I write this in matlab code where G_hat is MK matrix and E(g ̃kg ̃k) is a diagonal matrix with (b_mk - c_mk) on its m diagonal and P is a diagonal matrix with n_1, ..., n_K on its diagonal / ...
soso's user avatar
  • 1
-1 votes
0 answers
15 views

What are convenient packages/algorithms (Python or MATLAB) to detect when one is speaking?

Using a .wav file (of 12 hours long), I am interested in detecting the periods one was speaking (or not). A lot of the packages I have seen are about detecting speech content which I am on purpose not ...
user22409235's user avatar
0 votes
1 answer
15 views

Using MATLAB app designer and writecell in a for-loop. Misses getting the value of the first row/item in the for-loop

I have this .mlapp from App Designer, and I'm using it to loop through some audiofiles and then record what the listener heard. The listener types what they hear in the sentence into an edit text ...
shaedopotato's user avatar
0 votes
0 answers
23 views

Emacs - octave-mode: How to change comment character?

I'm using Emacs 27.1 with octave-mode 6.4.0 to edit Octave code for a class in Matlab. I'd like to change the character that octave-mode uses for comments from '## " to the Matlab standard "%...
Kevin Zembower's user avatar
1 vote
1 answer
26 views

Handle Class to avoid copies - problematic?

classdef DataContainer < handle properties d end end my_cells = DataContainer(); my_cells.d = cell(1, 100); func(my_cells) updated_data = my_cells.d{1:5}; Issues with such an ...
OverLordGoldDragon's user avatar
1 vote
2 answers
54 views

How to calculate powers and element-wise multiplication?

I need to convert the below line from Matlab into R z=(exp(j)).^(pw.*om) In the matlab code, there is powers (.^) and multiplication(.*) I have no idea how both are applied in r The data: rt=...
user22178063's user avatar
0 votes
0 answers
9 views

IDASolve Error when translating ODE from Matlab to Octave

I am currently trying to translate some scripts from Matlab to Octave, including an ODE solver. On Matlab the script runs smoothly, but Octave returns: [IDA ERROR] IDASolve At t = 0.00101 and h = 3....
Stoppelhopser's user avatar
0 votes
1 answer
34 views

What differences between win32 and win64 might cause error in executing mex file?

I am trying to run example provided by field II on my computer. This example contains matlab functions as well as mex32 file. I have later version of matlab so i take initial .c file and converted it ...
MarryD's user avatar
  • 1
0 votes
0 answers
9 views

Notch filtering in stereoelectroencephalography

How I can remove line noise on stereoEEG? . I have tried using: Fir filter Iir notch Butter notch filter Fieldtrip notch filter Comb filter. Have used higher order filters I expected the line noise ...
MAHIMA ELSA JOJI's user avatar
1 vote
0 answers
12 views

pyvisa use in Matlab for network-connected instruments

I am trying to use the 'pyvisa' library from within Matlab to communicate with VISA-supported instruments on the local network. Some of these instruments are attached through a GPIB-Ethernet bridge, ...
Carsten Langrock's user avatar
-1 votes
0 answers
15 views

Trying to understand region growing by cummulative differences

I need to make a region growing algorithm using the cumulative difference method on a medical image, but first I need to understand the subject, I found this article that talks about it, but only a ...
Luis Hernández's user avatar
0 votes
0 answers
20 views

Tools/ packages for drawing biological pathways and reactions (from system of ordinary differentiation equations) [closed]

I am trying to draw a huge set of ODEs that describe biological/ biochemical reactions. I know there are solvers in Python/ R/ Matlab (e.g. deSolve). I am not sure if there is a good way to visualize ...
William Wong's user avatar
0 votes
0 answers
20 views

mean function throws error "Index exceeds the number of array elements. Index must not exceed 1"

I am trying to find the arithmetic mean of a vector in MATLAB. However, when I pass my array into the mean function, it throws the error "Index exceeds the number of array elements. Index must ...
phantombees's user avatar
-1 votes
0 answers
26 views

How to vectorize a nexted for-loop in Matlab, that contains keyword continue + array? [closed]

Is it possible to vectorize this Matlab code that is a nested for-loop and contains continue + vector? The array K has not the same length as m or n. The code: m = 20; n = 30; X = randn(m, n); ...
euraad's user avatar
  • 2,537
0 votes
0 answers
10 views

(Robust) sigma estimate in statsmodels.api.RLM( )?

I'm am trying to port an algorithm from Matlab to Python. This algorithm uses the stats.s value from the robustfit function in Matlab, which I believe itself is based on (among others) the stats.ols_s ...
Bart Wolleswinkel's user avatar
-4 votes
0 answers
18 views

"Extract Epoch from EEG signal at Matlab without EEGLab" [closed]

I want to epoch healthy and unhealthy raw EEG dataset 301 times using for loop at Matlab software. I have total 28 subject dataset. How can I do this by using for loop at where it shows with specific ...
Swaraj Sharma's user avatar
0 votes
0 answers
17 views

Error in Executing the Simulink model 'Error in port widths or dimensions.'

I have the Simulink model. I want to execute the model. But while executing it, the model shows the error mentioned below: Error:Error in port widths or dimensions. 'Output Port 1' of '...
Urvesh's user avatar
  • 331
1 vote
1 answer
22 views

Matlab's parpool: How to specify directory for temp files?

On this website, it states that if one is working on an object of parcluster, one can use the property JobStorageLocation to modify the directory for temporary files. It seems the same is not working ...
Imahn's user avatar
  • 374
3 votes
5 answers
91 views

How to exit function early if outputs are not requested?

I'm writing a function that has multiple inputs and outputs. All the outputs are only needed on infrequent occasions. Moreover, some inputs are only used to generate some of the infrequent outputs. A ...
magnesium's user avatar
  • 334
0 votes
0 answers
23 views

The total sampling time stays unchanged, and the impact of reducing the sampling rate and number of samples on FFT

There is a time series X(t) with total times T, sample rate fs, and sample number N=fs*T. I used FFT in matlab your textand get the results: The result is as I expected In order to reduce the ...
k zhou's user avatar
  • 1
0 votes
0 answers
8 views

Matlab RCNN inputs without tables

I am trying to use the trainRcnnObjectDetector on R2020b (I have all toolboxes) and the example input is a table of image locations (allready created and loaded as a .mat). My images are frames in an ...
Dan's user avatar
  • 1
2 votes
2 answers
58 views

How do I access variables on Fortran from MATLAB using MEX (without copying them)?

I would to ask how I can access a variable on Fortran from MATLAB without making a copy. Preferrably, I would like to access the variable a variable on Fortran (it may be 'read-only') that was ...
Vinicius Oliveira Fontes's user avatar
0 votes
0 answers
19 views

In the following code I am getting the error "Index in position 2 exceeds array bounds. Index must not exceed 512. "

I want to apply the box filter and for some reason an error is showing up. Since I am very new to coding, I am not able to fix it myself as well. Why am I getting the error Index in position 2 ...
sayantani saha's user avatar
0 votes
0 answers
13 views

ramprate % /min rate limiter in simulink

how to implement running % /min in simulink ? I need to limit the Pwr (kw) output to 5%/min using a rate transition block. Im using the dynamic rate limiter block as follows but the calculation of %/...
user183060's user avatar
-1 votes
0 answers
20 views

i want to draw this DOP figure with these specific parametres

I want to draw this figure I tried using this script: t=0:0.1:2; q=exp(-t/0.4).*sin(2*50*t); plot(t,q); but the shape wasn't great and I didn't know how to control the parameters. I was looking to ...
Yoba's user avatar
  • 9
1 vote
1 answer
25 views

How to change the fontsize of xtick and xlabel separately in matlab heatmap?

I was using the matlab function heatmap and I got the following figure. The fontsize of 0, 0.05, ..., are fine. But I want to make xlabel 'Drive conversion rate' bigger. h = heatmap(x_values, ...
Aries Zi_Ye's user avatar
0 votes
1 answer
43 views

I want to know if there is solutions to improve my matlab program that find primes numbers compare to the primes fonction of matlab

I want to know if there is solutions to improve my matlab code that find primes numbers compare to the primes function of matlab My program is lower in time to find the primes numbers than the primes ...
David Strainchamps's user avatar
-1 votes
0 answers
33 views

Matlab double sum

I want to calculate double sum of f(k,k') over k and k', in which k and k' are vectors with x and y components. Both k and k' lie in the 1st Brillouin zone: -pi<kx<pi, -pi<ky<pi, -pi<kx'...
karren lim's user avatar
0 votes
1 answer
15 views

Matlab PCA scree plot - which variable was most important?

Less of a coding question, more of a "have I understood what I'm doing?" question. Conducting some PCA analysis of some data with up to 7 variables, and I want a scree plot to show me how ...
user2587726's user avatar
-7 votes
0 answers
63 views

Why is numpy's matrix inversion much slower than MATLAB?

Some time ago, I want to port my matlab code to python and I choose to use numpy module. When I run my code, I find the speed is much slower than it which is written by matlab. I test many parts of ...
hei boy's user avatar
1 vote
0 answers
60 views

How to write sub2ind in C code, from Matlab code

Assume that you have this matrix >> P = zeros(8, 12) P = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
euraad's user avatar
  • 2,537
2 votes
2 answers
47 views

Why is indexing via sub2ind not the same as indexing via A(i, j) in Matlab?

Assume that you have this matrix >> P = zeros(8, 12) P = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
euraad's user avatar
  • 2,537
1 vote
0 answers
17 views

Running matlab from terminal (windows) without opening a matlab command window

I am opening cmd on windows and running matlab using the instruction below: matlab.exe -nosplash -nodesktop -nojvm -wait -logfile "log2.txt" -r simulation_f(2) I would expect the "-...
phdstudent's user avatar
  • 1,060
0 votes
0 answers
7 views

problem of Error evaluating 'InitFcn' callback of MPC block (mask)?

how i diagnose this problem that i keep getting in simulate this model in simlink the error HERE_FILES (i will attack the model ) : Error evaluating 'InitFcn' callback of MPC block (mask) 'FB_MPC/...
TRicheT's user avatar
0 votes
1 answer
33 views

Roots of simultaneous quadratic equation in OCTAVE

How can I solve: y1 = -x1 + 2*x1^3 + x2 y2 = -x1 - x2 at y1 = 0, y2 = 0 I tried this function y = f(x) y(1) = -x(1) + 2*x(1)^3 + x(2); y(2) = -x(1) - x(2); endfunction fsolve("f&...
sumit_singh's user avatar
0 votes
0 answers
26 views

Fast generation of matrix for multiple variables that take the same vector of values [duplicate]

I have 6 variables, each variable takes every value in [1,2,3,4]. So the total combination is 4^6. I want a matrix as follows, 111111 111112 111113 111114 111121 ... 444444 I know I can just use 6 for ...
uPhone's user avatar
  • 313
0 votes
0 answers
19 views

Matlab code dimension error of k-means algorithm

Use K_mean algorithm to cluster data data. The cluster center is IRS and the number of clusters is IRS_num. However, sometimes an error will be reported. function [index_cluster,cluster] = kmeans_func(...
user22024727's user avatar
0 votes
0 answers
21 views

Plot custom ECDF in matlab

I try to plot custom empirical CDF in matlab for cauchy distribution. Below I present my code: clear clc format long % Parameters of the Cauchy distribution location = 17; % Location parameter (...
Alex 's user avatar
  • 197
0 votes
0 answers
30 views

Is there a way to make discrete signal plots in Java?

I want to make a discrete signal plot in Java, like when using the stem() command in matlab, such that when giving it an array for the x-axis and one for the y-axis, it makes like a scatter plot with ...
MrManini's user avatar
-3 votes
0 answers
20 views

how to make an matlab connection to digsilent using dll and interface? [closed]

problem is that digsilent doesnt load the dll I created from matlab simulink or visual studio I generated a dll from matlab coder and I expect power factory to use it as a dsl element Need some ...
java master's user avatar
1 vote
0 answers
25 views

Crash report of matlab under the macOS sonoma

Recencly i updated my macbook into macOS sonoma. After the updating, every time when I open the matlab 2023a, a crash report will appear. I cannot figure out the reason why it happen and how to fix it....
Daniel Han's user avatar
1 vote
0 answers
29 views

Pass Function Handle to ODE45 in Matrix

I'm trying to use ode45 to predict the behavior of the following system: I'm getting the following error with my Force matrix F: Since the forcing function changes with time, I made it a function ...
Jonathan Frutschy's user avatar
0 votes
0 answers
7 views

Using SimUserIncludeDirs when running Simulink model from the command line

I have a Simulink model that includes a lot of additional source code. The include folders are specified in the "Include Directories*" of the model Configuration Parameters. However, I need ...
ilya1725's user avatar
  • 4,496
0 votes
0 answers
9 views

How to combine AIC/ negative loglikelihood values in MATLAB to compare the goodness of fit [closed]

I want to compare the goodness of fit between the 2 models. In one of the model, I have individual AIC values per fit. Basically 4 AIC values from 4 SDT fits.I am just wondering if there is any ...
Rinku Sarkar's user avatar
1 vote
1 answer
54 views

Matlab exits without error upon clear mex with openMP

I ran into a weird case where Matlab closes without an error. I have the following mex file that uses OpenMP // main.cpp #include "mex.h" #include "omp.h" void mexFunction(int ...
rinkert's user avatar
  • 6,631
-1 votes
0 answers
21 views

Function 'quadprogIP' runs fast seperately but extremely slow in a for loop simulation

I am currently using the function 'quadprogIP' from https://github.com/xiawei918/quadprogIP This is a function that solves a nonconvex quadratic optimization, via IBM Cplex function for mixed-integer ...
Churui's user avatar
  • 1
0 votes
0 answers
19 views

Integration tolerances using ode23s

I have to solve a differential function using an ode solver (preferably ode23S) in order to plot the change of variables. Using fsolve earlier in the code to obtain initial (steady state) variables ...
Jacobus02's user avatar
-1 votes
0 answers
17 views

The first input to set_param must be of type 'double' or 'char'

I hava problem in matlab appdesigner I make an Edit Field as Text and my code is set_param(app.modelEditField,'SimulationCommand','update') I think first input of set_param is 'char' ('update') so ...
Dayoung's user avatar
0 votes
0 answers
34 views

MATLAB: "Index exceeds the number of array elements" error when solving a second-order differential equation

I am working on solving a second-order differential equation in MATLAB using finite differences. However, I keep encountering the error message "Index exceeds the number of array elements." ...
Web Inar's user avatar

1
2 3 4 5
1893