# Jan

It is easier to solve a problem than to guess, what the problem is.

Questions about FileExchange submissions are welcome - get my address from the code. I do not answer mails concerning questions in the forum.

**Statistics**

RANK**4**

of 250,073

REPUTATION**36,703**

CONTRIBUTIONS

**80** Questions

**13,981** Answers

ANSWER ACCEPTANCE **
77.5%
**

VOTES RECEIVED**8,608**

RANK**71** of 17,374

REPUTATION**12,032**

AVERAGE RATING**4.90**

CONTRIBUTIONS**52** Files

DOWNLOADS **333**

ALL TIME DOWNLOADS**106856**

CONTRIBUTIONS**0 Posts**

CONTRIBUTIONS**0** Public Channels

AVERAGE RATING

CONTRIBUTIONS**0** Highlights

AVERAGE NO. OF LIKES

**Content Feed**

BUTTER function returning slightly different results for Signal Processing Toolbox in R2020b and R2021a on same computer (Win10)

You can compare both results with this cheap implementation of a high pass Butterworth filter: format long g [num, den] = bu...

12 days ago | 0

My implemetation for Newton's method doesn't seem to be working

I've cleanup the code, e.g. removed the not needed "x_old". Avoid using the names of important Matlab functions as variables: ep...

12 days ago | 0

| accepted

Get plot lines title in a GUI plot by mouse click on each line

You can define a ButtonDownFcn for the lines: LineH(1) = plot(1:10, rand(1, 10), 'r', 'DisplayName', 'Line 1'); LineH(2) = plo...

17 days ago | 0

| accepted

Error on using ODE45 and cannot prompt output

I get a different error message, which is very clear: k=1e9; r = 4.31e-3; kt=0.9; D=1; timespan=[0 30]'; C0=40000; first=...

17 days ago | 0

Looping over an array using Fibonacci numbers as a range to calculate the mean

What should happen with the last chunk, if you cannot find enough elements in the input data? Should the 1st term really be: me...

17 days ago | 0

| accepted

Complexity comparison: remove a key-value pair from a containers.map vs removing an item from an array.

You can run a short test: function [] = MapTest figure; len = 1e3:5e4:1e6; tMap = zeros(1, numel(len)); for idx = 1:nu...

18 days ago | 1

How can I obtain the T and Y for R Runge Kutta method?

Store the first version starting with "function R=rk4(f,a,b,ya,M)" in a file called "rk4.m" and save it to a folder, which is i...

18 days ago | 0

| accepted

Gurobi mex file cannot be found despite it being clearly there

Use the Dependency Walker to find out, which library is missing: https://www.mathworks.com/matlabcentral/answers/95906-how-do-i...

18 days ago | 0

find the equal values that stand together on the same row or column or diagonal in the matrix

Maybe you mean: pool = [-1, 1, 2]; index = randi([1, 3], 15, 15); data = pool(index); match = conv2(data > 0, ones(3, 3)...

18 days ago | 1

Index in position 2 exceeds array bounds (must not exceed 1).

dx1dt = x4 .* cos(x5) .* cos(u3); % Now dx1dt is a scalar ... x(1,i) = x(1,i-1) + h * dx1dt(1,i-1); % This treats dx1dt ...

19 days ago | 0

| accepted

Storing values from a for loop

B = 1000; R2 = zeros(1, B); % Pre-allocation for iter = 1:B ... R2(iter) = 1 - sse / sst; end A problem is, that R...

19 days ago | 0

Newton's method - problems in calculating alpha value

In the lines: func = @(x) eps * c_s * x^4 + (alpha_k + 1/(s1/lamda1+s2/lamda2)) * x - ... ((1/(s1/lamda1+s2/lamda2...

23 days ago | 0

| accepted

how to declear global "import java.awt.Robot" and "import java.awt.event.*"?

If such a global import is possible, it might destroy Matlab's stability. The imported functions without wildcards have a higher...

24 days ago | 0

Performance of log() is wildly different in two different contexts and machines for same data?

Summary: On the 16 GB M1 MacBook, the lines tic tdg_log = log(tdg); toc displays, that the processing needs 1.5 seconds. U...

24 days ago | 0

Numerical integration of discrete data using higher precision

You explain, that you have discrete data, but the code you show uses a function. If the data are given in double precision, usin...

25 days ago | 0

Passing multiple Arrays to loop a Function and creating a 1 column array

The code contains some strange details: A = ArrayA; (1,000x1) Double Please use the standard notation. I assume this would be ...

29 days ago | 0

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

Let Matlab stop at the error using the debugger: dbstop if error Then run the code again. If it stops, chek the sizes of the u...

29 days ago | 0

how do I put waitbar inside a figure (Matlab 2016a)?

You find a lot of examples in the FileExange. Search there for "porgressbar": https://www.mathworks.com/matlabcentral/fileexcha...

29 days ago | 0

Calculationg with quternions Matlab function did not work

function p_A = q_transform_coordinate_vector(R_A_B, p_B) % ^^^^^ p_A = q_A_B * q_pu...

29 days ago | 1

| accepted

Error using reshape: Size arguments must be real integers. Except all values are positive whole numbers?

Change: raw_data.variable_mat = raw_data.variable_mat(:,1:reshape_val); to raw_data.variable_mat = raw_data.variable_mat(:,1:...

1 month ago | 1

| accepted

How to solve this error: =: nonconformant arguments (op1 is 1x1, op2 is 100x1)?

T = linspace(0, 10)'; % Time f = 0.1; % Frequency Am = 10; % Phase F = Am*sin(2*pi*f*T); % Sin wave input Now F is a [100, ...

1 month ago | 0

Can I hit the "OK" button on inputdlg through coding?

See this example for creating your own dialog with a timer: https://www.mathworks.com/matlabcentral/fileexchange/24871-autowarnd...

1 month ago | 0

Interpolation method of IMAGE

x = zeros(640, 480, 3); x(:, 1:2:end, :) = 1; image(x) This looks confusing to me in the online version: Where are the steps ...

1 month ago | 0

MEX-file efficiency with multiple file-pass function calls in .m script

Do you use the terms "function" and "script" correctly? Functions and scripts are stored in .m-files. Functions start with the ...

1 month ago | 0

Question

Submit button not working sometimes

A few weeks ago the Submit button in this forum stopped to work for me in about 50% of the cases. Then I copy my answer or comme...

1 month ago | 2 answers | 2

### 2

answersLinear indexing in 3D matrix

Look into the code of sub2ind. It is easy to create an inline version of what you want: s = [2, 3, 4]; x = reshape(1:prod(s), ...

1 month ago | 0

I am facing problem regarding storage of values for d() using for loop which is of 100x100 size for each iteration of a and k.

You overwrite the data by zeros repeatedly: for t=1:L for v=1:elements for w=1:elements % Here all f...

1 month ago | 0

removing zeros from matrix

x(x==0) = []; % Or: x = x(x~=0); Where do the zeros come from? Instead of removing them it might be easier to avoid to crea...

1 month ago | 0

Trisurf : How to interactively change the plot opacity?

GUIs are not hard to control. function testGUI % Some test data: [x,y] = meshgrid(1:15, 1:15); tri = delaunay(x,y); z = pea...

1 month ago | 0