# 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 273,159

REPUTATION**40,182**

CONTRIBUTIONS

**82** Questions

**15,093** Answers

ANSWER ACCEPTANCE **
78.05%
**

VOTES RECEIVED**9,270**

RANK**69** of 18,447

REPUTATION**12,454**

AVERAGE RATING**4.90**

CONTRIBUTIONS**52** Files

DOWNLOADS **360**

ALL TIME DOWNLOADS**110747**

CONTRIBUTIONS**0 Posts**

CONTRIBUTIONS**0** Public Channels

AVERAGE RATING

CONTRIBUTIONS**0** Highlights

AVERAGE NO. OF LIKES

**Content Feed**

Automating length with reshaping, and using reshape to loop through data.

See reshape - simply use [] for the free dimension to be adjusted automatically: tt = reshape(t, 3, []).' Note: While ' is the...

18 hours ago | 0

| accepted

error described on the command window does not appear on code analyzer

The code analyzer shows typing errors and other static problems. The error message you get is a run-time problem, which occurs ...

1 day ago | 0

how do i create a signal which is reset to zero every time the input signal increases of 1?

signal2 = diff(signal) == 1;

1 day ago | 1

Error in running the code

dlmread cannot handle the double quotes around the numbers. Use modern import functions instead, e.g. readmatrix(). The option '...

1 day ago | 0

I have a string with 10 variables created using randi, between 0 and 1, in the last 5 variables (i.e 5-10 variables) i want maximum 2 places with 1 only (eg:- 1011101001).

nVar = 10; last = 5; a = randi([0, 1], 1, nVar - last); b = zeros(1, last); n = randi([0, 2]); % 0, 1 or 2 b(rand...

2 days ago | 0

| accepted

How to simplify too much of if

Change: if (0<S)&&(S<=10) if AggS==10 if fap==40 if fwcr==0.5 fp=39; e...

2 days ago | 0

How to store values in matrix form for differn iteration

A = [6 3 4 5 2 7 1]; Collected = zeros(500, 7); for k = 1:500 A = rem(A + randi([0, 100], 1, 7), 10); % A random test fu...

3 days ago | 1

How to find number of bit change between binary numbers?

Step 1: Convert your input to a typical binary representation as a numerical vector [1,1,0] or char vector '110'. Step 2: XOR ...

3 days ago | 1

Find doesn't seem to work with Matrix larger than 127x127

This observation does not match the facts: X = randi([0, 1], 150, 150); [i,j] = find(X); max(i) max(j) If you observe a ver...

3 days ago | 0

interp2 from 6x6 map to 500x500 map

Of course, 1*(0:1/N_mesh:1) has N_mesh+1 points. "But the image is not centered at the extremes..." - What does this mean? By ...

4 days ago | 1

| accepted

Get special variable out of every struct in workspace

This is a bad coding design. Creating a bunch of variables causes much troubles. See here for an exhaustive discussion: https://...

6 days ago | 1

How to write this fuction in Matlab? I have an example code in Python

Assuming that b_1, b_2, r_1, r_2 are constants: % As anonymous function: r_1 = rand; % Define the constants r_2 = rand; b_1...

7 days ago | 1

| accepted

Why does my uicontextmenu only show after a pause/breakpoint?

Try to replace pause by drawnow. This allows the GUI to activate the updated properties. If this is working also, this is the ex...

8 days ago | 0

| accepted

Why do i get error when i reupload the GUI that i deleted before.

The solution is explained in the message clearly already: "Contact the File exchage If you want to upload the file again". Searc...

10 days ago | 0

| accepted

how to add header for new output file?

You want to copy the header? Read the first 15 lines and write it: [fid, msg] = fopen(file_paths{i}, 'r'); assert(fid > 0, msg...

10 days ago | 0

| accepted

i want the loop to run only one time, it keeps running until it subtract 84 instead of 6

Remember that length(A) replies the longest dimension. Maybe you meant height(A). Even if this replies the same value for the ex...

12 days ago | 0

Unexpected high memory usage in MATLAB.

Avoid clear all, because it has no benefits. It removes all loaded functions from the RAM and reloads them from the slow disk th...

12 days ago | 1

| accepted

Escaped character '\U' is not valid. See 'doc sprintf' for supported special support.

It is a typical bug under Windows, which does not occur, when the software is tested successfully in Linux: fprintf(['Current f...

12 days ago | 0

Detect if user has a valid MatLab license

The detection is not trivial. A matching license file might be there, but the license can be expired. The computer or license se...

12 days ago | 0

Generating 60 random samples that sum to 1, each subject to a unique lower and upper limit

Isn't this a job for: https://www.mathworks.com/matlabcentral/fileexchange/9700-random-vectors-with-fixed-sum ? % [x,v] = randf...

13 days ago | 0

checking if field values in a single struct are identical

Depending on how the inputs look exactly, maybe: FieldC = struct2cell(S); Eq = true; for k = 2:numel(FieldC) if ~isequal...

13 days ago | 0

Trying to extract data trail by trail, but my data is sampled at different sampling rate.

If one signal is measured with 1000 Hz and another with 2000 Hz, it is trivial to determine timepoints of the first one in the t...

13 days ago | 0

How not repeat the main loop, if other options are selected?

The description is not really clear. I assume, you want a list of menus to be selected one after the other. Then: status = 0; ...

14 days ago | 0

How can I generate the Radom number between two set of floating point number?

Gain0 = 0.0000250002787160545; Bias0 = -0.124315307973192; Gain = Gain0 + Gain0 * 0.18 * (rand(1, 160) - 0.5); Bias = Bias0...

14 days ago | 0

| accepted

How do I properly convert a 64-bit binary string / Convert directly from bin or hex to uint64

The question explains with many details, where the numbers are coming from. It would be more useful to post a set aof available ...

14 days ago | 0

Fast computation of entries of large matrix

n = 2500; x1=rand(n, 5); % some matrix with high number of rows and small number of columns > 1 x2=rand(n, 5); % anoth...

15 days ago | 0

2nd order euler method problem

You have to convert the 2nd order equation to a system of order 1 at first. Accumulating dx2/dt2 is not meaingful. The 2nd deri...

15 days ago | 0

I tried dragging an image into the edit box for an answer on Matlab Central and doing so destroyed my answer.

Yes, I can confirm this behavior. For Firefox/Windows: When I drag an image into the field for editing (or anywhere else on th...

15 days ago | 0

Renaming multiple files in a folder

Folder = 'C:\Your\Folder'; FileList = dir(fullfile(Folder), 'Antenna_REF_*.s2p'); for k = 1:numel(FileList) oldName = Fi...

15 days ago | 1

How to vectorize nested loops with conditional statements?

tributary = randn([81, 126]); cp_mesh = randn([81, 126, 49792]); tic cp_B1_2 = zeros(49792, 1); for i = 1:4979 % 49792 ...

16 days ago | 0

| accepted