# 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 243,992

REPUTATION**35,961**

CONTRIBUTIONS

**78** Questions

**13,760** Answers

ANSWER ACCEPTANCE **
79.49%
**

VOTES RECEIVED**8,426**

RANK**71** of 17,061

REPUTATION**11,919**

AVERAGE RATING**4.90**

CONTRIBUTIONS**52** Files

DOWNLOADS **378**

ALL TIME DOWNLOADS**105814**

CONTRIBUTIONS**0 Posts**

CONTRIBUTIONS**0** Public Channels

AVERAGE RATING

CONTRIBUTIONS**0** Highlights

AVERAGE NO. OF LIKES

**Content Feed**

How to get rid of a loop that depends on its previous iterations

Start with calculating the average manually instead of the slower mean() function: % Timings: R2018b, Win10, i7 data0 = rand(1...

1 hour ago | 0

| accepted

Solving problem with ODE45

In the loop you are calculating the integration from 0 to 2*t(i) with the initial value set to y2(i-1, :). But this is another i...

2 days ago | 0

Check for equality in the contents of two arrays ignoring order

unique, setdiff, union and ismember call the function sort also internally. So % assert(isequal(sort(A), sort(B))) Is a very e...

2 days ago | 0

How to identify duplicate values in an n dimensional array , then club the linked values related to it in another array

A = [ 1 8 10 4; ... 1 8 4 0]; T = isMultiple(A); B = A(T) % ? or what do you want? A(T) = 0; functi...

2 days ago | 0

Iteration Involving 1x4 matrix

while abs(P - Pgiven) > 1e-6 ... end

2 days ago | 0

| accepted

Conversion to double from function_handle is not possible.

objective = zeros(1,3); % Here objective is a double for i = 1:Nc % And here you want to store a function handle in the d...

2 days ago | 1

Issues running a Mex Function (.mexw64)

The leading "./" means, that it is searching in the current folder. Assuming, that the current folder is chosen as expected, is ...

3 days ago | 0

Why doesn't my function for writing a file work?

"Not enough input arguments" might mean, that you call this function without inputs. Therefore the most important part of the co...

4 days ago | 0

| accepted

Too many for loops, how to approach rearranging arrays problem differently?

Pre-allocate the output and avoid repeated calculations: a = 1:50; b = 10:50; tic aa = f2(a); bb = f2(b); for i = 1:le...

5 days ago | 0

I didn't know how to find r

a = 6 * 18 * 18 a = 4 * pi * r.^2 r = sqrt(6 * 18 * 18 / (4 * pi))

5 days ago | 0

Estimate the Value of Pi

Your code runs fine and it is clean. It can be simplified, but the application of the index a is valid. I'm not sure why your te...

6 days ago | 0

| accepted

Dot indexing is not supported for variables of this type - ISSUE?

Start with experimenting: img2 = reshape(img, [4, 376, 672]); rgb = permute(img2([3 2 1], :, :), [2, 3, 1]); figure, image(r...

6 days ago | 0

| accepted

Remez exchange Algorithm for approximation

if a <= M < x(2) if v(end-1)< M <= b if i < M < i+1 These commands will not do, what you want. The comparison is evaluated fr...

6 days ago | 0

| accepted

Not enough Input arguments

Stephen hits the point: >>qardlecm This shows, that you call the function without input arguments. Perhaps you start it by cli...

6 days ago | 1

My "plot" has some problems

Did you update the graphic drivers and install all updates of Matlab? Try different graphic modes: opengl software opengl har...

6 days ago | 0

| accepted

Need matrix or vector with 1,0,1,0,1,0.........

Do you now the colon operator already? a = 2; b = 15; a:b a:3:b You can use this to create an index of the values, you want...

7 days ago | 0

Maximizing along n-1 dimensions of an n-dimensional array without a for loop

VV = rand(8, 9, 10); for ii = 1:size(VV,1) Vtemp = squeeze(VV(ii, :, :)); [V(ii), I(ii)] = max(Vtemp(:)); end ...

7 days ago | 0

| accepted

convert BGRA8 image format to RGB format

Do you have the pixels values as UINT8 array already? Then: RGB = BGRA8(:, :, [3, 2, 1])

7 days ago | 1

| accepted

A function that counts the number of zeros in a vector

Beside sum(D == 0) nnz(D) This would be working also, if the elements are 0 or 1 only: numel(D) - sum(D)

7 days ago | 0

matrix array for loop

See the command: size() https://www.mathworks.com/help/matlab/ref/size.html By the way, you find such commands, when you know ...

7 days ago | 0

Reading visual basic code language like matlab?

There is no direct translation from Visual Basic code to Matlab code. The solution is to learn a programming language, if you wa...

7 days ago | 0

Does Matlab initialize random seed at each -batch run?

Yes, exactly as you observe the random number generator is initialized with the same seed. Use rng to get different seeds. See:...

7 days ago | 0

How to maximize the graph area in case of subplots ?

There is a bunch of solution in the FileExchange. Search for "subplot": https://www.mathworks.com/matlabcentral/fileexchange?q=...

7 days ago | 0

Equivalent of numpy.where() value choice parameters

Your code looks almost fine: x = 0:9 y = (0:9) * -0.1 z = zeros(size(x)); z(mod(x, 2) == 0) = x(mod(x,2) == 0); % ...

9 days ago | 0

| accepted

Understanding coding terminology - indexing

"Indexing" means to address an element of an array by using an index. Example: x = [3,1,4] index = 2 x(index) % reply: 1 T...

9 days ago | 0

calculation norm divided by square root of data length

r = [-33.1869365513747 - 7.19942077700726i 9.95754431609273 - 9.07572996519880i 5.11935460162031 - 9.45713125754552i 17.24067494...

9 days ago | 0

| accepted

How to filter out the elevation higher than 0

I do not see, where your filter out elevations greator 0. It is faster to call interp2 with vectors as coordinates. So avoid ca...

9 days ago | 0

| accepted

Alternatives for dir command

addpath \\winfs\data\prod\maprod\arkivering\TAF; Why do you append this folder to Matlab's path? Are the files stored in this f...

9 days ago | 0

| accepted

Multiplication between elements of two different cells

"first 36 row of F will be multiplied by the first row of T and next 36 row of F will be multiplied by second row of T and conti...

10 days ago | 0

| accepted

How to solve error "merge_sort: failed to get memory buffer"

This sounds like your memory is exhausted. Are you running out of RAM?

10 days ago | 0

| accepted