# 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 265 298

REPUTATION**39 083**

CONTRIBUTIONS

**80** Questions

**14 755** Answers

ANSWER ACCEPTANCE **
78.75%
**

VOTES RECEIVED**9 051**

RANK**71** of 18 130

REPUTATION**12 324**

AVERAGE RATING**4.90**

CONTRIBUTIONS**52** Files

DOWNLOADS **322**

ALL TIME DOWNLOADS**109519**

CONTRIBUTIONS**0 Posts**

CONTRIBUTIONS**0** Public Channels

AVERAGE RATING

CONTRIBUTIONS**0** Highlights

AVERAGE NO. OF LIKES

**Content Feed**

Compact way to calculate the centroid of a boundary of a set of points

The centroid of the boundary is the mean value of the coordinates: x = rand(40, 1).^2; % More points on the left y = rand(40,...

4 jours ago | 2

| accepted

Rotate Basis Vectors Programmatically

See: FEX: Rotation Matrix This creates N-dimensional rotation matrices.

4 jours ago | 0

| accepted

How to use cumsum function?

CG = 25; C = 0; for i = 1:size(B, 1) if B(i, 5) < 200 if C == 0 C = CG; else C...

4 jours ago | 0

How to speed up this calculation and remove loop(s)?

There is a very small potential for optimizing in the posted code: for row = 1:size(oFD,1) c1 = oFD.PS(row); c2 = oFD...

5 jours ago | 0

| accepted

Access data in cell and save as vector with corresponding variable name

Data = struct(); % [EDITED], was: struct([]); for k = 1:numel(tableCell) C = tableCell{k}; NameList = T.Properties.V...

5 jours ago | 0

| accepted

Vertcat error when concatenating images in loop

vertcat(Sro) concatenates Sro with nothing. What is the purpose of this command? Ask Matlab, what the problem is: for i = 1:le...

5 jours ago | 0

csv file to text file

% [UNTESTED CODE!] function Value = GetCSVElement(File, R, C) % INPUT: File: File name % R: Row index of wanted element. 1 r...

5 jours ago | 0

loop over variable with different characters

This shows, that you have created a bunch of variables and stored important information in the name of the variables. This desig...

5 jours ago | 0

| accepted

Efficient way to assign indices to variables in a matrix

[~, Result] = ismember(A, B(:, 4)); A look up table is even faster: Instead of searching the element A(i,j) in B(:, 4), create ...

5 jours ago | 0

Why sprint doesn't show a zero value from an array?

Reduce the clutter: a=[1:450:2251]; % Easier: a = 1:450:2251; [] is Matlab operator for a concatenation. [1:450:2251] concat...

5 jours ago | 0

| accepted

How to interleave data from 2 doubles of differing length?

A=[1420;2956;4492;6028]; B=[2960;3152;3344;3536;3728;3920;4112;4304;4496;4688;4880;5072;5264;5456;5648;5840]; [C, idx] = sor...

5 jours ago | 0

| accepted

Load multiple *.mat files and save outputs using loop without overwriting the previous file

filePattern = fullfile(myFolder, '*.mat'); theFiles = dir(filePattern); nFiles = numel(theFiles); % not size() Out = cell...

6 jours ago | 0

| accepted

How to know the exact colour after a level of transparency being applied?

The color you see through a semitransparent element depends on the background. The rule is simple: alpha = rand; % ...

7 jours ago | 0

| accepted

Remove the 1x1 Cell Array from the Cell Array

If you want D{1} = [2, 1], use: D{1} = [2, 1] % or equivalently D = {[2, 1]} Expanded: D = {[2,1], [1,2,0]} D{1} D{2} Ma...

7 jours ago | 0

| accepted

code no good :(

areaOriginal = area(widthOriginal,thicknessOriginal); This creates a diagram and returns the handle to the graphics object. ar...

8 jours ago | 0

How to treat select elements from within multiple cells as a single vector

C = cell(5, 4); C(:) = {2:5}; % Faster than with DEAL V = cellfun(@(x) x(1,1), C(2:end,1), 'UniformOutput', 1) V = ...

8 jours ago | 0

| accepted

Error while running matlab script from Linux terminal

Is this a script or function? Obviously it is not included in the PATH. So either change the current path or add the folder to t...

11 jours ago | 0

Add code to have switch repeat if a case is not met

knownLevels = {'easy', 'medium', 'hard'}; Levels = [10, 50, 100]; fprintf('\nChoose one of the known levels: %s\n', strjo...

13 jours ago | 0

When calling a user defined function, MATLAB throws an error for simple matrix multiplication

Use the debugger to examine the problem: dbstop if error Run your code again afterwards. If it stops at the error, check the d...

13 jours ago | 1

Is it possible to programmatically check whether MATLAB has been started with the "-sd" option?

PID = feature('getpid'); [status, out] = system(sprintf('ps -p %d -o args', PID)) Parsing the char vector out is not trival: E...

16 jours ago | 0

| accepted

Generating a combination matrix within a certain condition

After some test I could simplify the original combvec and including the limit is easy also: % Without limit, but considering th...

17 jours ago | 1

How can I apply filter with loop-based function instaed of using filter( ) : built in MATLAB function?

You can find a Matlab function for filtering here: https://www.mathworks.com/matlabcentral/answers/9900-use-filter-constants-to-...

17 jours ago | 0

Generating a combination matrix within a certain condition

It is easy to modify the code of a copy of Matlab's combvec function, which uses the class of the input: Change the zeros(., .) ...

18 jours ago | 1

How could I possibly iterate over three 3D arrays and use their variable names iteratively in the title and axes?

v_dx = struct('EField_h', EField_h(idx_phi,idx_theta,:), ... 'EField_v', EField_h(idx_phi,idx_theta,:), ... ...

18 jours ago | 0

| accepted

When I import google sheet into Matlab, I get the first line imported as the url for my google account sign in

If the file starts with <!doctype html><html lang="en-US" dir="ltr"><head> it is an HTML file, not a JSON file. Then jsondeco...

19 jours ago | 0

How to display a single element from a matrix?

Indexing is a fundamental Matlab method. To learn the basics asking in the forum is less efficient than using the tutorials: Ge...

19 jours ago | 0

How can I import multiple fig files into a single figure in a tiled layout?

Using a vector as 3rd input in subplot allows to span an axes over multiple blocks of the layout: FigH = figure; subplot(2, 3,...

19 jours ago | 0

When triying to oppen a .m file instead of the editor oppening, a command prompt appears

Open the section "Editor/Debugger" in Matlab's preferences and select "MATLAB editor" as editor.

19 jours ago | 1

| accepted

Artefacts when filtering a contiguous signal

The final state of the filter parameters after the 1st block is not the value of the signal. Replace: zi = vec1(end-2:end); % ...

19 jours ago | 1

| accepted