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

I have two 3d points, A(1,0,0) and B(0,1,0). And I connect these two points as a line AB. How to divide this line into 10 equally segments and get their coordinates?

A = [1, 0, 0]; B = [0, 1, 0]; ab = B - A; v = linspace(0, 1, 10).'; C = A + v .* ab

I have two 3d points, A(1,0,0) and B(0,1,0). And I connect these two points as a line AB. How to divide this line into 10 equally segments and get their coordinates?

A = [1, 0, 0]; B = [0, 1, 0]; ab = B - A; v = linspace(0, 1, 10).'; C = A + v .* ab

1 día ago | 0

Answered

how do i substract the first value from the last one on an array taking out zero values?

Get the corresponding indices: first = find(X, 1, 'first'); last = find(X, 1, 'last'); Result = X(last) - X(first)

how do i substract the first value from the last one on an array taking out zero values?

Get the corresponding indices: first = find(X, 1, 'first'); last = find(X, 1, 'last'); Result = X(last) - X(first)

2 días ago | 0

| accepted

Answered

how to solve this error: Error using ' TRANSPOSE does not support N-D arrays. Use PAGETRANSPOSE/PAGECTRANSPOSE to transpose pages or PERMUTE to reorder dimensions of N-D arrays

What is the size of u10 ? u10 = double(ncread(nc_windfile, 'u10')) ; size(u10) If it has more than 2 dimensions, u10' is not ...

how to solve this error: Error using ' TRANSPOSE does not support N-D arrays. Use PAGETRANSPOSE/PAGECTRANSPOSE to transpose pages or PERMUTE to reorder dimensions of N-D arrays

What is the size of u10 ? u10 = double(ncread(nc_windfile, 'u10')) ; size(u10) If it has more than 2 dimensions, u10' is not ...

3 días ago | 0

| accepted

Answered

How to calculate each result of f(x) in the nested for loop?

This is correct, but not useful: j = sqrt(-1); i and j are defined as imaginary units as default already. But you see the ambi...

How to calculate each result of f(x) in the nested for loop?

This is correct, but not useful: j = sqrt(-1); i and j are defined as imaginary units as default already. But you see the ambi...

4 días ago | 0

Answered

input and output functions

Name your function fibseq. So call it fibseq.m, not "Fibseq.m". The case matters in Matlab. It will have one input n and one ou...

input and output functions

Name your function fibseq. So call it fibseq.m, not "Fibseq.m". The case matters in Matlab. It will have one input n and one ou...

5 días ago | 1

| accepted

Answered

How to get a function from user without knowing its symbols

See how e.g. fzero and ode45 solves this problem. Here the function has 1 oder 2 variables which must be provided in a specific ...

How to get a function from user without knowing its symbols

See how e.g. fzero and ode45 solves this problem. Here the function has 1 oder 2 variables which must be provided in a specific ...

5 días ago | 0

Answered

hObject is not created when running GUIDE *.m file - what can be done?

The m-files created by GUIDE are not compatible with other Matlab versions You can expect such troubles.

hObject is not created when running GUIDE *.m file - what can be done?

The m-files created by GUIDE are not compatible with other Matlab versions You can expect such troubles.

5 días ago | 0

| accepted

Answered

Break loop with button click GUI [if button is pressed] [Both plot and button are in different functions]

function main FigH = figure; ButtonH = uicontrol(FigH, 'Style', 'PushButton', 'String', 'Stop', 'Call...

Break loop with button click GUI [if button is pressed] [Both plot and button are in different functions]

function main FigH = figure; ButtonH = uicontrol(FigH, 'Style', 'PushButton', 'String', 'Stop', 'Call...

5 días ago | 1

| accepted

Answered

Why Index exceeds the number of array elements (1) if I change the input order in the anonymous function?

ode45 calls the function to be integrated as f(t, Y) . So the time must be the first input.

Why Index exceeds the number of array elements (1) if I change the input order in the anonymous function?

ode45 calls the function to be integrated as f(t, Y) . So the time must be the first input.

5 días ago | 1

| accepted

Answered

Extract rows from 2 different matrices with different dimensions using If statement

if AR(:,5)==n; This is a vector in the condition. Therefore Matlab inserts an all() implicitly, because conditions of if statem...

Extract rows from 2 different matrices with different dimensions using If statement

if AR(:,5)==n; This is a vector in the condition. Therefore Matlab inserts an all() implicitly, because conditions of if statem...

5 días ago | 1

| accepted

Answered

inputdlg does not work Matlab 2020a

User the debugger to find out more details. Type in in the command window: dbstop if caught error Now run the code again and c...

inputdlg does not work Matlab 2020a

User the debugger to find out more details. Type in in the command window: dbstop if caught error Now run the code again and c...

5 días ago | 1

Answered

if statement/numel (A)

These condition does not do, what you expect: 1<=(i + a)<=numel(A) 1<=(i - a)<=numel(A) They are evaluated from left to right...

if statement/numel (A)

These condition does not do, what you expect: 1<=(i + a)<=numel(A) 1<=(i - a)<=numel(A) They are evaluated from left to right...

5 días ago | 0

Answered

How to find euclidean distances between cell entries of two RGB matrices?

A = rand(47, 47, 3); B = rand(1, 456 3); AB = reshape(A, 47*47, 1, 3) - B; Dist = vecnom(AB, 2, 3); And now you want to fi...

How to find euclidean distances between cell entries of two RGB matrices?

A = rand(47, 47, 3); B = rand(1, 456 3); AB = reshape(A, 47*47, 1, 3) - B; Dist = vecnom(AB, 2, 3); And now you want to fi...

13 días ago | 0

Answered

How do I use characters with an if statement?

Prompt = 'Please press any key to roll the dice, press Q or q to quit program: '; str = input(Prompt, 's'); if strncmpi(str...

How do I use characters with an if statement?

Prompt = 'Please press any key to roll the dice, press Q or q to quit program: '; str = input(Prompt, 's'); if strncmpi(str...

26 días ago | 0

Answered

Random draw without re-delivery in a loop

What are your input data? A list of files stored in a folder? (As usual: please explain this instead of letting the readers gues...

Random draw without re-delivery in a loop

What are your input data? A list of files stored in a folder? (As usual: please explain this instead of letting the readers gues...

alrededor de 1 mes ago | 0

| accepted

Answered

search in large cell file

In the loop all lines are stored in the cell an the loops stops, if the last one was not a CHAR. This means, that the last eleme...

search in large cell file

In the loop all lines are stored in the cell an the loops stops, if the last one was not a CHAR. This means, that the last eleme...

alrededor de 1 mes ago | 1

| accepted

Question

MEX api and interleaved complex arrays

Does MATLAB store complex data in interleaved format since R2018a? If you compile a MEX function with the -R2018a flag, you can...

alrededor de 1 mes ago | 1 answer | 0

Answered

Reversible matrix in matlab

You want to identify a "regular matrix and non-singular matrix". Then testing only, if it is square and not a zero matrix ist no...

Reversible matrix in matlab

You want to identify a "regular matrix and non-singular matrix". Then testing only, if it is square and not a zero matrix ist no...

alrededor de 1 mes ago | 0

Answered

Calculation precision changed in 2020b?

The ACOS function is numerically instable at 0 and pi. SUM is instable at all. A trivial example: sum([1, 1e17, -1]) .There are...

Calculation precision changed in 2020b?

The ACOS function is numerically instable at 0 and pi. SUM is instable at all. A trivial example: sum([1, 1e17, -1]) .There are...

alrededor de 1 mes ago | 1

Answered

Why stock DOT function is suboptimally implemented

Just a comment: Under Matlab 2018b, Core i5-3320M CPU @ 2.60GHz: Elapsed time is 0.249669 seconds. dot(z,z) Elapsed time is ...

Why stock DOT function is suboptimally implemented

Just a comment: Under Matlab 2018b, Core i5-3320M CPU @ 2.60GHz: Elapsed time is 0.249669 seconds. dot(z,z) Elapsed time is ...

alrededor de 1 mes ago | 0

Answered

How to concatenate matrices to calculate mean

As Steven has mentioned already, this is the main problem: "I have 40 matrices DJF1979_1980_125 to DJF2019_2020_125" Do not us...

How to concatenate matrices to calculate mean

As Steven has mentioned already, this is the main problem: "I have 40 matrices DJF1979_1980_125 to DJF2019_2020_125" Do not us...

alrededor de 1 mes ago | 0

Submitted

ScaleTime

Fast linear interpolation of equally spaced data (C-MEX and M)

alrededor de 1 mes ago | 17 downloads |

Answered

How to read data from a file into cell array keeping indents undisturbed

% Import file: Str = fileread('file.ext'); % Remove trailing line break to avoid appending an additional empty line: if ~is...

How to read data from a file into cell array keeping indents undisturbed

% Import file: Str = fileread('file.ext'); % Remove trailing line break to avoid appending an additional empty line: if ~is...

2 meses ago | 0

| accepted

Answered

Not enough input arguments error

What about replacing: for j= 1:N if x(j)<beta1 & x(j)>beta2 f(1,j)=f02(x(j)); end if x(j)>beta1 & x(j)<...

Not enough input arguments error

What about replacing: for j= 1:N if x(j)<beta1 & x(j)>beta2 f(1,j)=f02(x(j)); end if x(j)>beta1 & x(j)<...

2 meses ago | 0

Answered

command window no output

Check if you have shadowed the display function: w = cellstring(which('display', '-all')); fprintf('%s\n', w{:}) What do you ...

command window no output

Check if you have shadowed the display function: w = cellstring(which('display', '-all')); fprintf('%s\n', w{:}) What do you ...

2 meses ago | 0

Answered

Find string in the special file

S = fileread('R2_AS - Copy.txt'); i1 = [strfind(S, 'Szenario'), Inf]; i2 = strfind(S, 'has been created.'); width = numel(...

Find string in the special file

S = fileread('R2_AS - Copy.txt'); i1 = [strfind(S, 'Szenario'), Inf]; i2 = strfind(S, 'has been created.'); width = numel(...

3 meses ago | 0

Answered

Namelengthmax value in different operating systems

The value of namelengthmax depends on the Matlab version only. It is the same for all operating systems. Identifiers can have ...

Namelengthmax value in different operating systems

The value of namelengthmax depends on the Matlab version only. It is the same for all operating systems. Identifiers can have ...

3 meses ago | 0

Answered

Syntax Error using Fcn Block

You need round parentheses for indexing, not square brackets: (1/Mus)*(Ks*(u[3]-u[4])+Ct*(u([7]-u[2])+Kt*(u[6]-u[4])-u[5]) % =...

Syntax Error using Fcn Block

You need round parentheses for indexing, not square brackets: (1/Mus)*(Ks*(u[3]-u[4])+Ct*(u([7]-u[2])+Kt*(u[6]-u[4])-u[5]) % =...

3 meses ago | 0

| accepted

Answered

how to compute the number of image from subfolder ?

fullfile(('.\databasee\')) is exactly the same as its input: '.\databasee\'. The unnecessary parentheses are confusing only. To...

how to compute the number of image from subfolder ?

fullfile(('.\databasee\')) is exactly the same as its input: '.\databasee\'. The unnecessary parentheses are confusing only. To...

3 meses ago | 1

| accepted

Answered

Different machine precision for scalars and vectors?

The only difference is the display in the command window. Matlab tries to display vectors in an abbreviated format, execpt if yo...

Different machine precision for scalars and vectors?

The only difference is the display in the command window. Matlab tries to display vectors in an abbreviated format, execpt if yo...

3 meses ago | 1

| accepted