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

How to find position a input

z(m,n,i,ii) = (x(m)).^4'* sin(y(n)).^3'*cos(xx(i)).^2'*(yy(ii)); % Voodoo: ^ ^^ ^ ^ ^ ^ ^ ^ ...

How to find position a input

z(m,n,i,ii) = (x(m)).^4'* sin(y(n)).^3'*cos(xx(i)).^2'*(yy(ii)); % Voodoo: ^ ^^ ^ ^ ^ ^ ^ ^ ...

ongeveer 17 uur ago | 0

Answered

Why do I receive this error message?

The message seems to be clear already. Some graphic output let the graphics driver crash. Follow the instructions given in the m...

Why do I receive this error message?

The message seems to be clear already. Some graphic output let the graphics driver crash. Follow the instructions given in the m...

ongeveer 17 uur ago | 0

Answered

How to create a struct

str_rock = sprintfc('ROCK%d', rock_code); % Undocumented ROCK = cell2struct(str_rock(:), sub_rock(:));

How to create a struct

str_rock = sprintfc('ROCK%d', rock_code); % Undocumented ROCK = cell2struct(str_rock(:), sub_rock(:));

ongeveer 17 uur ago | 0

Answered

I am getting Index exceeds the number of array elements(1) error?

With guessing where the error occurs: dv_dt_p = -v(j)*dv_dx-(1/gamma)*((dt_dx)+(t(j)/rho(j))*drho_dx); dt_dt_p = -v(j)...

I am getting Index exceeds the number of array elements(1) error?

With guessing where the error occurs: dv_dt_p = -v(j)*dv_dx-(1/gamma)*((dt_dx)+(t(j)/rho(j))*drho_dx); dt_dt_p = -v(j)...

ongeveer 19 uur ago | 1

Answered

How to speed up my code?

if ismember(selectedBus, InjBus_moreZeroLines) ismember replies a vector, if the inputs are vectors. The if command requires a ...

How to speed up my code?

if ismember(selectedBus, InjBus_moreZeroLines) ismember replies a vector, if the inputs are vectors. The if command requires a ...

ongeveer 20 uur ago | 0

Answered

Error loading matlabprefs.mat

If removing the file helps for some time, a function is destroying the file. Then an approach is to scan, who is accessi ng the ...

Error loading matlabprefs.mat

If removing the file helps for some time, a function is destroying the file. Then an approach is to scan, who is accessi ng the ...

ongeveer 20 uur ago | 0

Answered

Can I put an fprint statement in a saveas command?

folder = 'D:\Your\Output'; n = 4; saveas(FigH, fullfile(folder, sprintf('File%03d.eps', n))); This creates the file: D:\...

Can I put an fprint statement in a saveas command?

folder = 'D:\Your\Output'; n = 4; saveas(FigH, fullfile(folder, sprintf('File%03d.eps', n))); This creates the file: D:\...

2 dagen ago | 0

Answered

How to extact bits from an image to a string separated with commas?

Your code produces a CHAR vector (a "string" is a different class). Now you explain, that there is an error, when you "try to op...

How to extact bits from an image to a string separated with commas?

Your code produces a CHAR vector (a "string" is a different class). Now you explain, that there is an error, when you "try to op...

2 dagen ago | 0

Answered

How to sum over indices i+j=k without using a for loop?

Because beta is determined inside the for i and for j loops, we can improve only the inner loops: r = 501; kmax = 501; p ...

How to sum over indices i+j=k without using a for loop?

Because beta is determined inside the for i and for j loops, we can improve only the inner loops: r = 501; kmax = 501; p ...

2 dagen ago | 0

Answered

Rotate 3D matrix

X = rand(2, 3, 4); Y1 = permute(X, [3,1,2]); size(Y1) Y2 = permute(X, [3,2,1]); size(Y2) By the way, "matrix" means 2D by ...

Rotate 3D matrix

X = rand(2, 3, 4); Y1 = permute(X, [3,1,2]); size(Y1) Y2 = permute(X, [3,2,1]); size(Y2) By the way, "matrix" means 2D by ...

2 dagen ago | 0

Answered

How do I get execute while else loop?

The == operator compares its arguments elementwise. This works only if one of the array is a scalar or if bother have the same s...

How do I get execute while else loop?

The == operator compares its arguments elementwise. This works only if one of the array is a scalar or if bother have the same s...

3 dagen ago | 0

Answered

Array Exponentials without For Loop?

A = [1 2 3]; B = [2 3]; C = A .^ (B.')

Array Exponentials without For Loop?

A = [1 2 3]; B = [2 3]; C = A .^ (B.')

3 dagen ago | 1

| accepted

Answered

Safely interrupt a script/function

You can open a small window, which contains a stop button. Pressing this button sets a local variable, which can be checked from...

Safely interrupt a script/function

You can open a small window, which contains a stop button. Pressing this button sets a local variable, which can be checked from...

6 dagen ago | 0

Answered

Open image in Gui from menu

Unrecognized property 'XLim' for class 'matlab.graphics.primitive.Image'. XLim belongs to the axes. In the line: handles.Image...

Open image in Gui from menu

Unrecognized property 'XLim' for class 'matlab.graphics.primitive.Image'. XLim belongs to the axes. In the line: handles.Image...

6 dagen ago | 0

Answered

How to operate properly with multidimensional matrices and cells.

"For the other two, however, it goes wrong:" No, nothing goes wrong. This is exactly what is expected and needed. Only the dis...

How to operate properly with multidimensional matrices and cells.

"For the other two, however, it goes wrong:" No, nothing goes wrong. This is exactly what is expected and needed. Only the dis...

6 dagen ago | 0

| accepted

Answered

Help needed in solving a matrix equation

A= [0,1;1,1]; B= [0,1;1,1]; Q= [2,0;0,4]; R= [0.5,0;0,0.25]; syms p11 p12 p21 p22 P = [p11, p12; p21, p22]; eqn = P * A + ...

Help needed in solving a matrix equation

A= [0,1;1,1]; B= [0,1;1,1]; Q= [2,0;0,4]; R= [0.5,0;0,0.25]; syms p11 p12 p21 p22 P = [p11, p12; p21, p22]; eqn = P * A + ...

8 dagen ago | 1

Answered

I dont know what to do

Remove the semicolons from these lines: x; y1; y2; y3; y4; The trailing semicolon suppresses the output. Therefore "x;" sh...

I dont know what to do

Remove the semicolons from these lines: x; y1; y2; y3; y4; The trailing semicolon suppresses the output. Therefore "x;" sh...

8 dagen ago | 1

Answered

FiltFilt function giving NaN values

I try to run your code guessing some inputs: srate = 1000; [b, a] = ellip(14, 5, 30, 2*(170/srate), 'low'); lpfSig = filtfil...

FiltFilt function giving NaN values

I try to run your code guessing some inputs: srate = 1000; [b, a] = ellip(14, 5, 30, 2*(170/srate), 'low'); lpfSig = filtfil...

9 dagen ago | 0

Answered

How to insert data with fopen ?

fmt = [repmat('%.2f ', 1, 32). '\n']; ftempd = fopen('tempd.r2c', 'w'); fprintf(ftempd, fmt, tempd.'); fclose(ftempd);

How to insert data with fopen ?

fmt = [repmat('%.2f ', 1, 32). '\n']; ftempd = fopen('tempd.r2c', 'w'); fprintf(ftempd, fmt, tempd.'); fclose(ftempd);

9 dagen ago | 0

Answered

Run into "Paused: Press any key"

This problem appeared in R2016a already: https://www.mathworks.com/matlabcentral/answers/278430-why-does-program-execution-hang-...

Run into "Paused: Press any key"

This problem appeared in R2016a already: https://www.mathworks.com/matlabcentral/answers/278430-why-does-program-execution-hang-...

10 dagen ago | 0

Answered

Formating all values of a structure field

No, you cannot access nested fields of a struct array in Matlab directly. You need a loop.

Formating all values of a structure field

No, you cannot access nested fields of a struct array in Matlab directly. You need a loop.

10 dagen ago | 0

| accepted

Answered

Cheat for preallocation requirement

x = []; for i = 1:1e5 x(end+1, :) = 1:10; end Here you allocate sum(1:1e5) * 10 * 8 bytes: 400 GB. c = {}; for i=1:1e5...

Cheat for preallocation requirement

x = []; for i = 1:1e5 x(end+1, :) = 1:10; end Here you allocate sum(1:1e5) * 10 * 8 bytes: 400 GB. c = {}; for i=1:1e5...

10 dagen ago | 0

Answered

the user will be asked to input number which is good but the problem is how can I make that as numbers and letters for example 2x and put it in matrix

This is a really complicated task, which is prone to bugs. How do you want to treat "2x" compared to "x2"? If "x" is a variable,...

the user will be asked to input number which is good but the problem is how can I make that as numbers and letters for example 2x and put it in matrix

This is a really complicated task, which is prone to bugs. How do you want to treat "2x" compared to "x2"? If "x" is a variable,...

10 dagen ago | 0

Answered

Subtract 1 from variable each second

counter = 100; TimerH = timer('TimerFcn', @doCount, 'ExecutionMode', 'fixedRate', ... 'Period', 1.0, 'UserData', counter...

Subtract 1 from variable each second

counter = 100; TimerH = timer('TimerFcn', @doCount, 'ExecutionMode', 'fixedRate', ... 'Period', 1.0, 'UserData', counter...

10 dagen ago | 0

| accepted

Answered

Copy Multiple figures to the clipboard

The OS has a single clipboard only. There are some 3rd party apps, which offer more bins in the clipboard, but it is not easy to...

Copy Multiple figures to the clipboard

The OS has a single clipboard only. There are some 3rd party apps, which offer more bins in the clipboard, but it is not easy to...

10 dagen ago | 0

Answered

Hi; Someone please help me, how to do the same code with a set of images with a loop, and save only the first slice of each image?

See: FAQ: Sequence of files

Hi; Someone please help me, how to do the same code with a set of images with a loop, and save only the first slice of each image?

See: FAQ: Sequence of files

10 dagen ago | 0

Answered

How do I store the values of a for loop in a matrix array?

One solution might be indexing the output ... mat(u, u0, v, v0) = delta2(u, u0, v, v0); ... But this can be simplifi...

How do I store the values of a for loop in a matrix array?

One solution might be indexing the output ... mat(u, u0, v, v0) = delta2(u, u0, v, v0); ... But this can be simplifi...

11 dagen ago | 0

Answered

Recover Corrupt Matlab File

What do you call "Matlab files"? which file extension do they have? M, P, MAT, MLX, ...? Based on the information "random chara...

Recover Corrupt Matlab File

What do you call "Matlab files"? which file extension do they have? M, P, MAT, MLX, ...? Based on the information "random chara...

11 dagen ago | 0

| accepted

Answered

Concatenating multiple cells in a single matrix

The conversion from numeric to string and back to numeric is an expensive indirection. n = 8; % p = uint64(2).^(0:n-1); % LSB...

Concatenating multiple cells in a single matrix

The conversion from numeric to string and back to numeric is an expensive indirection. n = 8; % p = uint64(2).^(0:n-1); % LSB...

11 dagen ago | 0

Answered

An UndefinedFunction error thrown by parfor but not for

Constants defined in scripts cannot be identified by the Matlab, when it parses the parfor block. In addition such scripts have ...

An UndefinedFunction error thrown by parfor but not for

Constants defined in scripts cannot be identified by the Matlab, when it parses the parfor block. In addition such scripts have ...

11 dagen ago | 3

| accepted