5,581 total contributions since 2014

Suspensa Vix Via Fit

Answered

how to loop through subfolders and apply a particular function

A simple function which correctly handles special characters in the pattern and actually calls the nested function recursively: ...

how to loop through subfolders and apply a particular function

A simple function which correctly handles special characters in the pattern and actually calls the nested function recursively: ...

3 days ago | 0

Answered

replacing uiget with pathname and filename

You use dir without any specific name+wildcards, so it will return all contents of that folder (i.e. files and folders). You the...

replacing uiget with pathname and filename

You use dir without any specific name+wildcards, so it will return all contents of that folder (i.e. files and folders). You the...

3 days ago | 1

| accepted

Answered

finding the right values for a vector

Use mrdivide: >> V = (1:15).'; >> a = pi; >> M = a/V M = 0.0025335 0.0050671 0.0076006 0.0101342 0.0126677 0.0...

finding the right values for a vector

Use mrdivide: >> V = (1:15).'; >> a = pi; >> M = a/V M = 0.0025335 0.0050671 0.0076006 0.0101342 0.0126677 0.0...

3 days ago | 1

Answered

get the value of element from matrix

Simply use ismember and basic MATLAB indexing: >> [X,Y] = ismember(B,A(:,1:2),'rows'); >> Z = A(Y(X),:) Z = 9 9 ...

get the value of element from matrix

Simply use ismember and basic MATLAB indexing: >> [X,Y] = ismember(B,A(:,1:2),'rows'); >> Z = A(Y(X),:) Z = 9 9 ...

4 days ago | 0

| accepted

Answered

Finding corresponding values in double arrays in structure fields

Note that these methods assume that there is exactly one match per row. If this is not the case, then there is no way to disting...

Finding corresponding values in double arrays in structure fields

Note that these methods assume that there is exactly one match per row. If this is not the case, then there is no way to disting...

5 days ago | 2

| accepted

Answered

filling a matrix with a loop

"Does anyone know how to do this?" This is simple and efficient with toeplitz: >> C = [1,zeros(1,399)]; >> R = [1,1,0,1,zeros...

filling a matrix with a loop

"Does anyone know how to do this?" This is simple and efficient with toeplitz: >> C = [1,zeros(1,399)]; >> R = [1,1,0,1,zeros...

6 days ago | 3

| accepted

Answered

anyway to translate this command using 'cellfun'

Note that it is simpler to use strfind: >> C = strfind(test,'_'); >> C{:} ans = 2 ans = 2

anyway to translate this command using 'cellfun'

Note that it is simpler to use strfind: >> C = strfind(test,'_'); >> C{:} ans = 2 ans = 2

6 days ago | 0

| accepted

Answered

Create a matrix with random integers between 1 and 9

>> reshape(randperm(9),3,3) ans = 6 8 2 3 5 4 7 1 9

Create a matrix with random integers between 1 and 9

>> reshape(randperm(9),3,3) ans = 6 8 2 3 5 4 7 1 9

6 days ago | 0

| accepted

Answered

Meaning imaginary result of asin(x) function of MATLAB

"'My question is how can we interpret this imaginary number? Does it have any meaning? Yes, it has a meaning. Why does MATLAB ...

Meaning imaginary result of asin(x) function of MATLAB

"'My question is how can we interpret this imaginary number? Does it have any meaning? Yes, it has a meaning. Why does MATLAB ...

7 days ago | 1

Answered

What `gcbf` stands for?

gcbf get callback figure gcbo get callback object These are not necessarily the current ones.

What `gcbf` stands for?

gcbf get callback figure gcbo get callback object These are not necessarily the current ones.

7 days ago | 1

| accepted

Answered

Sorting columns of cell Array

Either download my FEX submission natsort: https://www.mathworks.com/matlabcentral/fileexchange/34464-customizable-natural-orde...

Sorting columns of cell Array

Either download my FEX submission natsort: https://www.mathworks.com/matlabcentral/fileexchange/34464-customizable-natural-orde...

7 days ago | 1

| accepted

Answered

the problem of using 'case'

Your first (inadvisable, numerically fragile, should-be-avoided) concept works for me: for omega = 0.1:0.1:2; switch omega ...

the problem of using 'case'

Your first (inadvisable, numerically fragile, should-be-avoided) concept works for me: for omega = 0.1:0.1:2; switch omega ...

8 days ago | 1

| accepted

Answered

Search a matrix combined with logical indexing

>> A = [3,10,2,5;2,14,5,3] A = 3 10 2 5 2 14 5 3 >> N = 10; >> B = A.*(cumsum(A>N,2)>0) B = 0...

Search a matrix combined with logical indexing

>> A = [3,10,2,5;2,14,5,3] A = 3 10 2 5 2 14 5 3 >> N = 10; >> B = A.*(cumsum(A>N,2)>0) B = 0...

9 days ago | 0

| accepted

Answered

Storing multiple value in array without overriding.

"How to avoid that?" Simply by changing the Excel worksheet name on each iteration of the outer loop, e.g.: ... for z=1:nfile...

Storing multiple value in array without overriding.

"How to avoid that?" Simply by changing the Excel worksheet name on each iteration of the outer loop, e.g.: ... for z=1:nfile...

10 days ago | 0

| accepted

Answered

How to create a for loop through a directory for only certain folders in the directory

An efficient MATLAB solution: P = 'absolute/relative path to the parent directory Sample'; S = dir(fullfile(P,'sub*')); F = {...

How to create a for loop through a directory for only certain folders in the directory

An efficient MATLAB solution: P = 'absolute/relative path to the parent directory Sample'; S = dir(fullfile(P,'sub*')); F = {...

10 days ago | 0

Answered

How can I make an array of structs , each struct have a unique index?

"How can I make an array of structs , each struct have a unique index?" Easily: https://www.mathworks.com/help/matlab/matlab_pr...

How can I make an array of structs , each struct have a unique index?

"How can I make an array of structs , each struct have a unique index?" Easily: https://www.mathworks.com/help/matlab/matlab_pr...

10 days ago | 0

| accepted

Answered

Regular Expressions using regexp

Matching only integer numbers after 'UZK' or 'T_' (it is unclear in your question if the underscore is permitted or not, but the...

Regular Expressions using regexp

Matching only integer numbers after 'UZK' or 'T_' (it is unclear in your question if the underscore is permitted or not, but the...

10 days ago | 1

| accepted

Answered

How to read elements from a computed matrix without define a new variable?

MATLAB does not allow indexing into the results of operations. You can either use a temporary variable (which is probably the mo...

How to read elements from a computed matrix without define a new variable?

MATLAB does not allow indexing into the results of operations. You can either use a temporary variable (which is probably the mo...

10 days ago | 0

| accepted

Answered

Matrix Maipulation and adding from variables in the workspace

Load the file into a variable (which is a structure) and access its fieldnames: S = load(...)

Matrix Maipulation and adding from variables in the workspace

Load the file into a variable (which is a structure) and access its fieldnames: S = load(...)

10 days ago | 0

Answered

ERROR-The statement cannot be reached

Those warnings are very simple to understand by aligning the code and looking at the values. MATLAB warns you that lines 14 and...

ERROR-The statement cannot be reached

Those warnings are very simple to understand by aligning the code and looking at the values. MATLAB warns you that lines 14 and...

11 days ago | 2

| accepted

Answered

Using semicolon for input argument when working with a matrix function

" I was thinking concatination, concatinating the same matrix 4 times but multiplying it by 1,2,3, then 4 as requested." It wou...

Using semicolon for input argument when working with a matrix function

" I was thinking concatination, concatinating the same matrix 4 times but multiplying it by 1,2,3, then 4 as requested." It wou...

11 days ago | 1

Answered

Comma separated value to vector

>> S = '11,333,4445,2,78,2399'; >> V = sscanf(S,'%f,',[1,Inf]) V = 11 333 4445 2 ...

Comma separated value to vector

>> S = '11,333,4445,2,78,2399'; >> V = sscanf(S,'%f,',[1,Inf]) V = 11 333 4445 2 ...

11 days ago | 0

| accepted

Answered

Replacing individual Values in Data column based on a condition

idx = myData.fluid_p_rel<0.9 | myData.fluid_p_rel>1.2; myData.fluid_p_rel(idx) = 1

Replacing individual Values in Data column based on a condition

idx = myData.fluid_p_rel<0.9 | myData.fluid_p_rel>1.2; myData.fluid_p_rel(idx) = 1

11 days ago | 0

| accepted

Answered

How to convert column datetime to datenum?

It is not clear from your example what class data has: a table or a non-scalar structure or .. ? In any case, datetime objects ...

How to convert column datetime to datenum?

It is not clear from your example what class data has: a table or a non-scalar structure or .. ? In any case, datetime objects ...

12 days ago | 1

| accepted

Answered

Error when calling a function : "Dimensions of arrays being concatenated are not consistent."

The full error message is this: Error using vertcat Dimensions of matrices being concatenated are not consistent. Error in fu...

Error when calling a function : "Dimensions of arrays being concatenated are not consistent."

The full error message is this: Error using vertcat Dimensions of matrices being concatenated are not consistent. Error in fu...

12 days ago | 2

| accepted

Answered

Counting zeros in array

Simpler: >> V = [1,-2,-1,-1,-1,0,0,-1,0,0,0,3,0,0,4,0,0,0,0,0]; >> X = find([V(1:end-1),1]); >> Z = [diff([1,X+1])-1;V(X)].' ...

Counting zeros in array

Simpler: >> V = [1,-2,-1,-1,-1,0,0,-1,0,0,0,3,0,0,4,0,0,0,0,0]; >> X = find([V(1:end-1),1]); >> Z = [diff([1,X+1])-1;V(X)].' ...

13 days ago | 3

Answered

Converting binary like table but using decimal values

You can use comma-separated lists on the output of ndgrid: https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-li...

Converting binary like table but using decimal values

You can use comma-separated lists on the output of ndgrid: https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-li...

13 days ago | 0

| accepted

Answered

How do i compare cell array values and replace with string of code letters?

Method one: >> C = {'UUU','CUU','UUC','UUG'}; >> F = {'UUU','UUC'}; >> L = {'UUA','UUG','CUU','CUC','CUA','CUG'}; >> Xf = is...

How do i compare cell array values and replace with string of code letters?

Method one: >> C = {'UUU','CUU','UUC','UUG'}; >> F = {'UUU','UUC'}; >> L = {'UUA','UUG','CUU','CUC','CUA','CUG'}; >> Xf = is...

13 days ago | 0

| accepted

Answered

How to get nearest values in matrix and save indexes of these values?

>> X = [5,10,15]; >> Y = 0:7/5:30; >> [~,Z] = min(abs(X-Y(:))) % the indices of the closest values: Z = 5 8 12 ...

How to get nearest values in matrix and save indexes of these values?

>> X = [5,10,15]; >> Y = 0:7/5:30; >> [~,Z] = min(abs(X-Y(:))) % the indices of the closest values: Z = 5 8 12 ...

14 days ago | 2

| accepted

Answered

Operation on structure fields with common part of the field name

S.DUT_2 = 2; S.REF_2 = 3; S.DUT_4 = 4; S.REF_4 = 5; C = fieldnames(S); U = unique(regexp(C,'\d+$','once','match')) F = @(n...

Operation on structure fields with common part of the field name

S.DUT_2 = 2; S.REF_2 = 3; S.DUT_4 = 4; S.REF_4 = 5; C = fieldnames(S); U = unique(regexp(C,'\d+$','once','match')) F = @(n...

14 days ago | 0

| accepted