# 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 242.622

REPUTATION**35.611**

CONTRIBUTIONS

**78** Questions

**13.663** Answers

ANSWER ACCEPTANCE **
79.49%
**

VOTES RECEIVED**8.354**

RANK**71** of 16.974

REPUTATION**11.882**

AVERAGE RATING**4.90**

CONTRIBUTIONS**51** Files

DOWNLOADS **323**

ALL TIME DOWNLOADS**105457**

CONTRIBUTIONS**0 Posts**

CONTRIBUTIONS**0** Public Channels

AVERAGE RATING

CONTRIBUTIONS**0** Highlights

AVERAGE NO. OF LIKES

**Content Feed**

Avoid ode15s from freezing in parameter optimization

I've limite the time to [0, 15]. You see that one component explodes between t=15 and t=16. This let the step size of the integr...

2 giorni ago | 0

How increase calculate speed in for loop

Start with a simplification of the code: Depth = 5000; Num_Alines = 400; Num_Bscan = 300; Alines = 180 h ...

2 giorni ago | 0

How to add integers without correction?

a = int8(126); b = int8(2); tic for k = 1:1e4 c = bitadd1(a, b); end toc tic for k = 1:1e4 c = bitadd2(a, b);...

2 giorni ago | 1

Solving a System of ODEs using Euler's method

Your function to be integrated depends on t also. You call this x in the Euler method. At is easier to use vector equations: f...

2 giorni ago | 0

Matlab versions supported on Windows 11?

Windows 11 have not been officially released yet. We and MathWorks cannot know how the final version will work. There have been ...

2 giorni ago | 0

How to Copy Upper diagonal elements of matrix A into a new matrix.

A = [1 2 3 4; 2 1 3 4; 1 1 1 2; 1 0 0 1]; B = triu(A)

2 giorni ago | 0

| accepted

why are some integrals not solvable in matlab?

Is it a numeric or symbolic integration? Most functions do not have a closed form integral. This is a mathematical limitation. ...

2 giorni ago | 0

Diagonals in Matrices Matlab

I'm not sure if I can follow your explanations. A short example might be useful. The term "be -.25 for every 2 instances" might...

3 giorni ago | 1

| accepted

I have 2011a on my machine. I installed 2014a. it is always running MATLAB2014a, how to select MATLAB2011 for running please?

How do you start Matlab? The exact method to start a specific Matlab version depend on the operating system. But the way is to i...

3 giorni ago | 0

Trying to use a for loop to calculate years with an IF statement but it seems to ignore it.

Either for M = 2:300 if balance(M) >= 50000 %balance(M) break; % Leave the for M loop end % NOPE ! M =...

3 giorni ago | 0

How to plot a smooth curve with only a few points?

Either decide for a linear interpolation: x = 1:6; y = rand(1, 6); plot(x, y, 'ko'); hold on xx = linspace(1, 6, 100); ...

3 giorni ago | 0

| accepted

Is rsqrt the same as Fast inverse square root?

i = * ( long * ) &y This is equivalent to: y = single(pi); i = typecast(y, 'int32'); The shown code of Q_rsqrt is an ap...

3 giorni ago | 0

I am getting Undefined function or variable 'A', error in Untitled line 95

The variable A should be polulated in this line: A(rr,:,z) = [sod,rangeL1,rangeL2]; If A in undefined, this line was not c...

3 giorni ago | 0

| accepted

ODE45 is taking hours and hours to compute

Symbolic omputations need a lot of time. Can you implement the code numerically? If the equation to be integrated is stiff, ODE...

3 giorni ago | 0

semilogy, loglog do not work in order to set the y axis on a logarithmic scale

After figure, hold on the YScale is determined already. Define it explicitly instead and you plot(): figure axes('yscale', 'lo...

4 giorni ago | 0

| accepted

About 3 significant digit?

fprintf('%.3g\n', pi) fprintf('%.3g\n', pi * 1e6) fprintf('%.3g\n', pi * 1e-6)

5 giorni ago | 0

"Too many output arguments" error while working with the fmincon solver inside the optimization tool.

A bold guess: [solution,objectiveValue] = fmincon(@objectiveFcn,w,[],[],[],[],[],[],... @objectiveFcn,options2); % ^^^^...

5 giorni ago | 0

Arithmetic coding and Huffman

https://www.mathworks.com/help/comm/ref/arithenco.html https://www.mathworks.com/help/comm/ref/huffmanenco.html Man further c...

5 giorni ago | 0

Calculation of the average of 80X80 blocks of 800X1280 Excel sheet data

Import the data. Then you have a [800 x 1280] matrix. It does not matter, if the data have been stored in an Excel file. Then: ...

5 giorni ago | 0

| accepted

Build array from for loop

n = 100; c = cell(1, n); for k = 1:n c{k} = rand(1, randi(10)); end result = cat(2, c{:}); This avoids an iteratively g...

6 giorni ago | 0

| accepted

Nested struct arrays with variable format

You can't. S = struct('Name1', cell(n1, 1), ... 'Name2', cell(n1, 1)) his creates a [n1 x 1] struct array with two...

6 giorni ago | 0

| accepted

finding divisibility in every number from 1 to 25

If x can by divided by y: rem(x, y) == 0 Or: x / y == round(x / y) Another apporach is to calculate the list of multiples of...

6 giorni ago | 0

Central difference method or Diff for trajectories?

There are different methods for numerical differentiation. Assume you have the positions store in x and the times in t. Then: F...

6 giorni ago | 1

| accepted

Find equal pentagonal and square number

And a two-liner: n = 1:10000; find(any(((3*n.^2 - n)/2) == (n.^2).')) Matlab can be very elegant. Do you understand the detai...

6 giorni ago | 0

Find equal pentagonal and square number

This sounds like a homework question. Then the standard way is that you post, what you have tried so fas and ask a specific ques...

7 giorni ago | 0

| accepted

for loop stack the data

Maybe: col = cell(1, 176); row = cell(1, 176); for k = 77:176 [col{k}, row{k}] = find(M == k); end

7 giorni ago | 0

how can i solve the error Reference to non-existent folder

I guess, that the code is not: ficheiro = fullfile(files(5), files(5).name); % but: ficheiro = fullfile(files(5).folder, file...

7 giorni ago | 0

calculating combinations of two vectors simultanously?

a = [1, 3, 5, 7, 9]; b = [2, 4, 6, 8, 10]; index = nchoosek(1:numel(a), 3); a(index) b(index)

7 giorni ago | 0

Converting 1 and 2 to False and True

result = [1; 2; 1; 1; 2]; Pool = {'FALSE', 'TRUE'}; Pool((result == 1) + 1)

8 giorni ago | 0

Creating a counter inside the ode45 function

This is not useful. ODE45 has a stepsize controller, which rejectes steps if they do not match the tolerances. This means, that ...

8 giorni ago | 0