12,464 total contributions since 2009

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 store a variable in a vector?

iVec = 0.001:0.001:0.999999; result = zeros(1, numel(iVec)); for k = 1:numel(iVec) i = iVec(k); ... your code r...

How to store a variable in a vector?

iVec = 0.001:0.001:0.999999; result = zeros(1, numel(iVec)); for k = 1:numel(iVec) i = iVec(k); ... your code r...

3 hours ago | 0

| accepted

Answered

How to optimize the computing process of a matrix ?

Pre-allocate the output of loops. Example: num = zeros; for nn=1:length(Y) NUM = size(Y{1,nn}); num(nn...

How to optimize the computing process of a matrix ?

Pre-allocate the output of loops. Example: num = zeros; for nn=1:length(Y) NUM = size(Y{1,nn}); num(nn...

6 hours ago | 2

Answered

Trying to run a script many times and combine all the results

eList = cell(1, 100); for k = 1:100 callYourScript; eList{k} = e; end A cell array is useful, if the elements, here...

Trying to run a script many times and combine all the results

eList = cell(1, 100); for k = 1:100 callYourScript; eList{k} = e; end A cell array is useful, if the elements, here...

13 hours ago | 0

| accepted

Answered

monte carlo simulation in matlab two dices roll

n = 10; % Number or trials throw = randi(6, n, 2); % Value of throws, 2 dice SumThrow = sum(throw, 2...

monte carlo simulation in matlab two dices roll

n = 10; % Number or trials throw = randi(6, n, 2); % Value of throws, 2 dice SumThrow = sum(throw, 2...

13 hours ago | 0

| accepted

Answered

Euclidean distance of two vectors

Do you know the definition of the Euclidean distance? G = rand(1, 72); G2 = rand(1, 72); D = sqrt(sum((G - G2) .^ 2)); A m...

Euclidean distance of two vectors

Do you know the definition of the Euclidean distance? G = rand(1, 72); G2 = rand(1, 72); D = sqrt(sum((G - G2) .^ 2)); A m...

13 hours ago | 31

| accepted

Answered

Matlab 2015a unable to find C++ compiler in windows10 even after installing microsoft professional C++ 2012. Can anyone help? I initially tried installing SDK7.1 but i was gettting .net framework4 installation errors.

https://www.mathworks.com/matlabcentral/answers/233850-how-can-i-install-sdk-7-1-on-windows-10 https://www.mathworks.com/matlab...

Matlab 2015a unable to find C++ compiler in windows10 even after installing microsoft professional C++ 2012. Can anyone help? I initially tried installing SDK7.1 but i was gettting .net framework4 installation errors.

https://www.mathworks.com/matlabcentral/answers/233850-how-can-i-install-sdk-7-1-on-windows-10 https://www.mathworks.com/matlab...

4 days ago | 0

Answered

Hi guys. I need help splitting a number into its individual parts and then add them. E.g. the number would be 1994 = 1 + 9 + 9 + 4 = 23

N = 1994; m = floor(log10(N)); D = mod(floor(N ./ 10 .^ (m:-1:0)), 10); >> D = [1, 9, 9, 4]

Hi guys. I need help splitting a number into its individual parts and then add them. E.g. the number would be 1994 = 1 + 9 + 9 + 4 = 23

N = 1994; m = floor(log10(N)); D = mod(floor(N ./ 10 .^ (m:-1:0)), 10); >> D = [1, 9, 9, 4]

4 days ago | 0

Answered

P files cannot be analyzed to find their dependencies. Please add P file dependencies manually

I'd start with a web search: Ask your favorite search engine for "Matlab get dependencies of P file". You will find e.g.: https...

P files cannot be analyzed to find their dependencies. Please add P file dependencies manually

I'd start with a web search: Ask your favorite search engine for "Matlab get dependencies of P file". You will find e.g.: https...

5 days ago | 2

| accepted

Answered

Stepping Through Text Documents

See https://www.mathworks.com/matlabcentral/answers/57446-faq-how-can-i-process-a-sequence-of-files A more specific answer is p...

Stepping Through Text Documents

See https://www.mathworks.com/matlabcentral/answers/57446-faq-how-can-i-process-a-sequence-of-files A more specific answer is p...

6 days ago | 0

Answered

Output argument "px" (and maybe others) not assigned during call to "function1"

If the initial value of varx is smaller than tol already, the body of the while varx>=tol loop is not entered at all. Then e.g. ...

Output argument "px" (and maybe others) not assigned during call to "function1"

If the initial value of varx is smaller than tol already, the body of the while varx>=tol loop is not entered at all. Then e.g. ...

6 days ago | 0

| accepted

Answered

where is the the porblem in audiowrite?

In the original question you write: AUDIOWRITE('test.wav',s,srate) In the comment you mention: audiowrite('test.wav',s,t) Th...

where is the the porblem in audiowrite?

In the original question you write: AUDIOWRITE('test.wav',s,srate) In the comment you mention: audiowrite('test.wav',s,t) Th...

6 days ago | 0

Answered

How can I open a file in a compiled application?

The error message is clear in this point: You cannot use open in compiled applications. This is not a limitation by the trial ve...

How can I open a file in a compiled application?

The error message is clear in this point: You cannot use open in compiled applications. This is not a limitation by the trial ve...

6 days ago | 0

Answered

Permission to write into text file

Do not use 'mojo.txt' as file name without a path. Remember, that any GUI or timer callback could call cd to change the current ...

Permission to write into text file

Do not use 'mojo.txt' as file name without a path. Remember, that any GUI or timer callback could call cd to change the current ...

6 days ago | 0

| accepted

Answered

I am having this error. Could you help?

The error message is clear: You provide a name, which is not an existing file. What is exactly hidden in the omitted rest of: T...

I am having this error. Could you help?

The error message is clear: You provide a name, which is not an existing file. What is exactly hidden in the omitted rest of: T...

6 days ago | 0

Answered

How to append cell arrays with a very specific form

Or: C = {... 'Rating1' [] [] [] '8'; ... 'Rating1' [] [] '3' []; ... 'Rating1' '2' [] [] []; ... 'Rating1' [] '4' [...

How to append cell arrays with a very specific form

Or: C = {... 'Rating1' [] [] [] '8'; ... 'Rating1' [] [] '3' []; ... 'Rating1' '2' [] [] []; ... 'Rating1' [] '4' [...

6 days ago | 0

Answered

Error using mex 'No supported compiler was found' on Mac.

Posting the error message offers new insights. Did you try this already - in a command shell of the operating system: sudo xcod...

Error using mex 'No supported compiler was found' on Mac.

Posting the error message offers new insights. Did you try this already - in a command shell of the operating system: sudo xcod...

6 days ago | 0

Answered

Shuffle binary vector (n0 = n1) with constraints: number of consecutive repetitions

A brute force approach: function V = ShuffledVector x = 100; % Number of elements, assumed to be even Z = 5; V = [true(1, x...

Shuffle binary vector (n0 = n1) with constraints: number of consecutive repetitions

A brute force approach: function V = ShuffledVector x = 100; % Number of elements, assumed to be even Z = 5; V = [true(1, x...

6 days ago | 2

| accepted

Answered

how to calculate the area under a curve?

The area between a curve and the X axis is determined by the integral. So use trapz: x = 0:100; % Square brackets waste time ...

how to calculate the area under a curve?

The area between a curve and the X axis is determined by the integral. So use trapz: x = 0:100; % Square brackets waste time ...

7 days ago | 0

Answered

Writing data to a structure array without loop

As written by Stephen before: There is no vectorized way to set the value of sub-fields of struct arrays. The expression [ax(...

Writing data to a structure array without loop

As written by Stephen before: There is no vectorized way to set the value of sub-fields of struct arrays. The expression [ax(...

11 days ago | 0

| accepted

Answered

How can I vectorize this function with nested FOR loop?

n = 1000; L = rand(24, n); T = zeros(n, 1); for i=1:n K = exp(-4*sum((L(:,i) - L) .^ 2, 1) ./ sum(L(:,i).^2, 1)); ...

How can I vectorize this function with nested FOR loop?

n = 1000; L = rand(24, n); T = zeros(n, 1); for i=1:n K = exp(-4*sum((L(:,i) - L) .^ 2, 1) ./ sum(L(:,i).^2, 1)); ...

11 days ago | 0

Answered

which matlab is compatible with windows 10, 64bit machine?

I'm running Matlab R2009a with the Signal Processing toolbox successfully under Windows 10. The installation and setup of the Me...

which matlab is compatible with windows 10, 64bit machine?

I'm running Matlab R2009a with the Signal Processing toolbox successfully under Windows 10. The installation and setup of the Me...

12 days ago | 0

Answered

Difficulty storing Output from Loop (Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 2-by-1)

To store arrays of different sizes, use a cell array: KMaxSBPFullTime = cell(1, 19); for i = 1:19 KMaxSBPFullTime{i} = ... ...

Difficulty storing Output from Loop (Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 2-by-1)

To store arrays of different sizes, use a cell array: KMaxSBPFullTime = cell(1, 19); for i = 1:19 KMaxSBPFullTime{i} = ... ...

12 days ago | 0

| accepted

Answered

Which way of programming is more efficient and faster?

%Case 1 X = 1; Y = X + 4; Z = X + Y; %Case 2 X = 1; Y = X + 4; Z = X + Y; The documentation of Matlab stated, that the J...

Which way of programming is more efficient and faster?

%Case 1 X = 1; Y = X + 4; Z = X + Y; %Case 2 X = 1; Y = X + 4; Z = X + Y; The documentation of Matlab stated, that the J...

13 days ago | 2

Answered

having problem to solve somthing in matlab

S = sum(x) is equivalent to S = 0; for k = 1:numel(x) S = S + x(k); end If you want to, you can call this as a subfunc...

having problem to solve somthing in matlab

S = sum(x) is equivalent to S = 0; for k = 1:numel(x) S = S + x(k); end If you want to, you can call this as a subfunc...

13 days ago | 0

Answered

Nested loop problem with the second index

The problem of you code was cp(i.*j,:). i*j is not a growing index. In the 1st iteration 1*1 is fine. For i=1 it works for the c...

Nested loop problem with the second index

The problem of you code was cp(i.*j,:). i*j is not a growing index. In the 1st iteration 1*1 is fine. For i=1 it works for the c...

13 days ago | 0

| accepted

Answered

Can I overwrite a function in a compiled program with a custom version?

This will not work. And if it works, it would conflict with the license conditions. Do not provide parameters as M-functions, b...

Can I overwrite a function in a compiled program with a custom version?

This will not work. And if it works, it would conflict with the license conditions. Do not provide parameters as M-functions, b...

14 days ago | 0

| accepted

Answered

MATLAB DualCPU Hyper-Threading support

Yes. Matlab will use the available cores. At least most likely. Matlab might split the array columnwise and if the input has 5 c...

MATLAB DualCPU Hyper-Threading support

Yes. Matlab will use the available cores. At least most likely. Matlab might split the array columnwise and if the input has 5 c...

15 days ago | 0

| accepted

Answered

Can anyone help me to understand the logic of below code

Start with a simplification of the code to make it easier to read: % find the points in the front surface for z = min(Zb):max(...

Can anyone help me to understand the logic of below code

Start with a simplification of the code to make it easier to read: % find the points in the front surface for z = min(Zb):max(...

15 days ago | 0

Answered

Text files for export the data

Storing numerical data in text files has the disadvantage, that the values need to be converted twice. Prefer storing the data i...

Text files for export the data

Storing numerical data in text files has the disadvantage, that the values need to be converted twice. Prefer storing the data i...

15 days ago | 0

Answered

how to change the bit of any matrix?

A = [12, 23, 32, 14]; B = bitset(A, 4, 0) Or: S = de2bi(A); S(:, 4) = 0;

how to change the bit of any matrix?

A = [12, 23, 32, 14]; B = bitset(A, 4, 0) Or: S = de2bi(A); S(:, 4) = 0;

15 days ago | 0

| accepted