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.

Answered

Array indices must be positive integers or logical values.

What is z1 and z2? Are these vectors? Then the message means, that z2((x(a)-x0)^2/z2^2+1) is not a valid expression, because ...

Array indices must be positive integers or logical values.

What is z1 and z2? Are these vectors? Then the message means, that z2((x(a)-x0)^2/z2^2+1) is not a valid expression, because ...

23 hours ago | 1

Answered

2D Interpolation with different sized matrices

A bold guess of what "corresponding x value when the y and z values are provided" means: x = [1 2 3 4 5]; y = [1 2 3 4 5]; z ...

2D Interpolation with different sized matrices

A bold guess of what "corresponding x value when the y and z values are provided" means: x = [1 2 3 4 5]; y = [1 2 3 4 5]; z ...

24 hours ago | 0

Answered

How to append for each iteration?

hournum = 10; projectlength = 3; yield = cell(1, projectlength); % Pre-allocate as cell helper = zeros(1, hournum); % P...

How to append for each iteration?

hournum = 10; projectlength = 3; yield = cell(1, projectlength); % Pre-allocate as cell helper = zeros(1, hournum); % P...

24 hours ago | 0

| accepted

Answered

Functions in If Statements

This: for n = 1:FMn %cycle through files in the directory finalname = FMdir(n).name; end does the same as: finalname = ...

Functions in If Statements

This: for n = 1:FMn %cycle through files in the directory finalname = FMdir(n).name; end does the same as: finalname = ...

3 days ago | 0

Answered

How to code sparse diagonal matrix of increasing dimensions

Maybe this is not, what you want: for n = 500:50:1000 tic t1(n) = toc; end Setting t(500) in the 1st step ist not u...

How to code sparse diagonal matrix of increasing dimensions

Maybe this is not, what you want: for n = 500:50:1000 tic t1(n) = toc; end Setting t(500) in the 1st step ist not u...

3 days ago | 0

Answered

line and column of the minimun element of a matrix

m = [5 1 -400; ... -6 100 -6; 2 5 25]; [~, ind] = min(m(:)); [row, col] = ind2sub(size(m), ind) Or: [v, ind1]...

line and column of the minimun element of a matrix

m = [5 1 -400; ... -6 100 -6; 2 5 25]; [~, ind] = min(m(:)); [row, col] = ind2sub(size(m), ind) Or: [v, ind1]...

3 days ago | 1

| accepted

Answered

Problem with changing visibility of pop-up list

What is the purpose of: % Update handles structure guidata(hObject, handles); For some unknown reasons the value ...

Problem with changing visibility of pop-up list

What is the purpose of: % Update handles structure guidata(hObject, handles); For some unknown reasons the value ...

3 days ago | 0

Answered

-If else- conditionals in matlab app.designer?

if strcmp(app.menu.Value, 'ac') && ... or define the values as string with double quotes, not as "cell string", which...

-If else- conditionals in matlab app.designer?

if strcmp(app.menu.Value, 'ac') && ... or define the values as string with double quotes, not as "cell string", which...

3 days ago | 0

Answered

Min and max value of many results

Use a vectorized method to obtain the results as a vector, not as a bunch of single variables: w = 0:0.001:1.393; k = 2; ...

Min and max value of many results

Use a vectorized method to obtain the results as a vector, not as a bunch of single variables: w = 0:0.001:1.393; k = 2; ...

6 days ago | 2

Answered

Unrolling a 20x20 grid of pixels into a 400 dimensional vector.

If the data are a collection of 500 matrices of the size 20x20: data = rand(5000, 20, 20) You can create the 2D matrix by: da...

Unrolling a 20x20 grid of pixels into a 400 dimensional vector.

If the data are a collection of 500 matrices of the size 20x20: data = rand(5000, 20, 20) You can create the 2D matrix by: da...

7 days ago | 0

Answered

what is the probleme exactly u must be of size[3,20] but i find it [3,1]

Let me guess boldly: You want: A = [5/8, -1/4, 1/8; 1/4, 0, 1/4; 1/8, -1/4, 5/8]; b = [1;-1;1]; u = [5; 2; -4]; m = 20; u =...

what is the probleme exactly u must be of size[3,20] but i find it [3,1]

Let me guess boldly: You want: A = [5/8, -1/4, 1/8; 1/4, 0, 1/4; 1/8, -1/4, 5/8]; b = [1;-1;1]; u = [5; 2; -4]; m = 20; u =...

7 days ago | 0

Answered

Vector ODE using forward Euler method

You have replaced the "x" of the formula by "y(1)", the "y" by "y(2)". Now you have to replace "u" by "y(3)" also and "v" by "y(...

Vector ODE using forward Euler method

You have replaced the "x" of the formula by "y(1)", the "y" by "y(2)". Now you have to replace "u" by "y(3)" also and "v" by "y(...

9 days ago | 1

Answered

how to convert grey image to RGB

Your Pi is a [130 x 130 x 60] matrix, but your function gray2rgb() expects a 2D matrix as input. It is not clear how you want to...

how to convert grey image to RGB

Your Pi is a [130 x 130 x 60] matrix, but your function gray2rgb() expects a 2D matrix as input. It is not clear how you want to...

10 days ago | 0

Answered

imread reads PNG files as empty arrays

When I run your code in Matlab 2018b I get a different result: img = imread('18_1b.png'); size(img) % 500 x 500 x 3, not...

imread reads PNG files as empty arrays

When I run your code in Matlab 2018b I get a different result: img = imread('18_1b.png'); size(img) % 500 x 500 x 3, not...

10 days ago | 0

Answered

Increment components of vector till a desired limit

You know in advance how many iterations are needed: The smallest element must be increased until it is 100. A = [1 2 3 4 5...

Increment components of vector till a desired limit

You know in advance how many iterations are needed: The smallest element must be increased until it is 100. A = [1 2 3 4 5...

10 days ago | 1

| accepted

Answered

Making sure the maximum calculated value in my function is represented in ode15s output.

ODE15S is designed to integrate smooth functions, as the other ODE integrators of MATLAB are. Running it with this not different...

Making sure the maximum calculated value in my function is represented in ode15s output.

ODE15S is designed to integrate smooth functions, as the other ODE integrators of MATLAB are. Running it with this not different...

10 days ago | 1

| accepted

Answered

Derivative without diff function

"Not enough input arguments. Error in @(x,t)x/t" You have defined fun to use 2 input arguments: fun = @(y,t) y/t; But in fun...

Derivative without diff function

"Not enough input arguments. Error in @(x,t)x/t" You have defined fun to use 2 input arguments: fun = @(y,t) y/t; But in fun...

11 days ago | 0

Answered

Get all unique combinations from cell array for use as functional arguments

This can be achieved by 2 loops using linear indexing: for i1 = 1:numel(data) for i2 = 1:numel(data) immse(data{i...

Get all unique combinations from cell array for use as functional arguments

This can be achieved by 2 loops using linear indexing: for i1 = 1:numel(data) for i2 = 1:numel(data) immse(data{i...

11 days ago | 0

Answered

Combining cell arrays with empty doubles

Or simpler: a = {1, []}; b = {[], 2}; c = cat(2, a, b); c = c(~cellfun('isempty', c)); % Or: fullCell = @(x) x(~cellfu...

Combining cell arrays with empty doubles

Or simpler: a = {1, []}; b = {[], 2}; c = cat(2, a, b); c = c(~cellfun('isempty', c)); % Or: fullCell = @(x) x(~cellfu...

11 days ago | 0

Answered

Why I get this message?

Use the debugger to check the sizes of the arrays: dbstop if error Type this in the command line and run the code again. When ...

Why I get this message?

Use the debugger to check the sizes of the arrays: dbstop if error Type this in the command line and run the code again. When ...

11 days ago | 0

Answered

Appending to a very large file

This line increases the problem: signal_mat = vertcat(signal_mat,temp_2); In e.g. the last step, you concatenate a 63 GB array...

Appending to a very large file

This line increases the problem: signal_mat = vertcat(signal_mat,temp_2); In e.g. the last step, you concatenate a 63 GB array...

12 days ago | 0

Answered

How would I convert a script to a function?

All you have to do to convert it to a function, is to add a head line: function array = randArrGen Maybe you want to define n ...

How would I convert a script to a function?

All you have to do to convert it to a function, is to add a head line: function array = randArrGen Maybe you want to define n ...

12 days ago | 0

Answered

check for keyboard press while using another application (such as Chrome)

The key should be caught, while the browser is the active window? This is a keyboard sniffer and running it might be conflict wi...

check for keyboard press while using another application (such as Chrome)

The key should be caught, while the browser is the active window? This is a keyboard sniffer and running it might be conflict wi...

12 days ago | 0

Answered

Keeping the debugger out of the bowels of the machine...dbstop error question

This can be avoided by an exhaustive error checking, which catchs all not matching inputs as early as possible. Massive TRY-CATC...

Keeping the debugger out of the bowels of the machine...dbstop error question

This can be avoided by an exhaustive error checking, which catchs all not matching inputs as early as possible. Massive TRY-CATC...

12 days ago | 0

| accepted

Answered

How to return values of differential, not the function, from odefun, ode45?

You want the values of dy2dt? But you do have the equation for it already: dy2dt = (param.m2*y4^2*y1-param.k*y1+param.k*param.l...

How to return values of differential, not the function, from odefun, ode45?

You want the values of dy2dt? But you do have the equation for it already: dy2dt = (param.m2*y4^2*y1-param.k*y1+param.k*param.l...

12 days ago | 0

Answered

Append rows at the end of matrix for loop

A = rand(5, 2); B = rand(3, 2); Result = cell(1, 3); for k = 1:3 Result{k} = [A; B(k, :)]; end

Append rows at the end of matrix for loop

A = rand(5, 2); B = rand(3, 2); Result = cell(1, 3); for k = 1:3 Result{k} = [A; B(k, :)]; end

12 days ago | 0

Answered

C++ Blur function to MATLAB code

You have redefined the function name "sum" as name of a variable. After sum=sum(A(:)) the symbol "sum" is a variable. The next t...

C++ Blur function to MATLAB code

You have redefined the function name "sum" as name of a variable. After sum=sum(A(:)) the symbol "sum" is a variable. The next t...

12 days ago | 0

| accepted

Answered

Two files with equal contents but with different SHA256 digest

The TIF files do not even have the same file sizes. How could you expect, that they are bit-wise identical then, which is requir...

Two files with equal contents but with different SHA256 digest

The TIF files do not even have the same file sizes. How could you expect, that they are bit-wise identical then, which is requir...

16 days ago | 0

| accepted

Answered

Find maximum array values avoiding mat2cell.

For the expanded question in the comment to Bruno's solution you ask for the n largest elements: A = [NaN, NaN, NaN, NaN, 1, 6,...

Find maximum array values avoiding mat2cell.

For the expanded question in the comment to Bruno's solution you ask for the n largest elements: A = [NaN, NaN, NaN, NaN, 1, 6,...

20 days ago | 2

Answered

Creating dynamic variables using loops | Automatic Variables using loops

[EDITED]: The direction for shiftig needs a minus sign and is applied along dimension 1: Ha = [1 2 4 8 16; ... ...

Creating dynamic variables using loops | Automatic Variables using loops

[EDITED]: The direction for shiftig needs a minus sign and is applied along dimension 1: Ha = [1 2 4 8 16; ... ...

20 days ago | 1

| accepted