Answered
how to find similar points in two different matrices
Use ismembertol: >> X = ismembertol(M,N,'ByRows',true); >> C = M(X,:) C = 224 345

7 years ago | 0

| accepted

Answered
regexp for time - cannot guess it
This is easy with a conditional expression based on the fourth token (decimal point) match: >> rgx = '(?<hh>\d{2})(?<mm>\d{2})(...

7 years ago | 1

Answered
How can I use assignin and eval together in function
Your code concept forces you to write slow, complex, obfuscated, buggy, and hard to debug code: https://www.mathworks.com/matla...

7 years ago | 1

| accepted

Answered
How to create a loop
A geometric series really is simpler to write using vectorized code: k = (1+ge)/(1+y); e0 * k.^(0:13)

7 years ago | 0

Answered
Calculating the strangeness using k constant
>> a = [0.6164;3.1654;0.5745;2.9883;0.9381;2.1817]; >> c1 = sort(a(1:2:end)); >> c2 = sort(a(2:2:end)); >> K = 2; >> sum(c1(...

7 years ago | 0

Answered
Remove some numbers from an array and replace them with zero?
>> A = [4,4,4,4,6,6,6,6,6,6,2,2,3,3,3,5,5,5,5,5,3,3,3] A = 4 4 4 4 6 6 6 6 6 6 2 2 3 3 3 5 5 5 5 5 3 3 ...

7 years ago | 0

| accepted

Answered
Convert number to string problem
>> V = [9,8,0,-5,-6]; % your data should be in one array. >> S = sprintf(', %+g',V(1:end-1)); >> S = sprintf('The numbers are%...

7 years ago | 0

Answered
Process data from sequentially named folders each having a file with the same name
To get the subfolders in numeric order download my FEX submission natsortfiles: https://www.mathworks.com/matlabcentral/fileexc...

7 years ago | 0

| accepted

Answered
Alternative to for/while cycle
"a possible option should be the replacement of the for and while cycles with another option" Why do you think that the loops t...

7 years ago | 1

| accepted

Answered
Add some elements of one matrix with another
Using a straightforward loop: C = {[1,2;3,4],[5,6;7,8],[9,10;11,12],[13,14;15,16]}; A = cat(3,C{:}); % not strictly required, ...

7 years ago | 2

| accepted

Answered
how to insert data at a certain positions in .txt file?
str = fileread('test3.txt'); str = regexprep(str,'(")\s*(\d)','$1\n$2'); [fid,msg] = fopen('test4.txt','wt'); assert(fid>=3,m...

7 years ago | 1

| accepted

Answered
Finding Duplicate rows?
Simpler using hist (or its more recent equivalents): >> A = [1,2;2,3;2,1;3,5;4,6;5,3] % I added an extra row A = 1 2 ...

7 years ago | 2

Answered
Sort matrix by increasing values (with doubles) and return indices to then sort secondary cell structure
You appear to be overthinking things. If you want to sort something, just use sort: >> [wo,idx] = sort(weight(:)); >> do = dat...

7 years ago | 0

| accepted

Answered
Error using Cos, not enough input arguments
cos^2*(pi/2) % incorrect cos(pi/2)^2 % correct Your code has several other syntax errors, such as: Ox % what does t...

7 years ago | 0

| accepted

Answered
How to search for channel name and numerical data in resulting struct after importing multiple data files?
You are right to avoid dynamically accessing variable names (e.g. using eval, assignin, evalin, and load without an output varia...

7 years ago | 0

| accepted

Answered
Sorting from highest to lowest for a particular column
Simpler and no loops required with sub2ind: >> X = sub2ind(size(A),B(:,2),B(:,3)); >> C = [B(:,1),A(X),B(:,4:end)] C = 1...

7 years ago | 1

| accepted

Answered
Saving characters from a loop
No loop required: V = 'LW'; Z = V(1+(scores(:,6)>scores(:,7)))

7 years ago | 0

Answered
Index Exceeds Array Bounds
You swapped around the function inputs. The function is defined like this: Jacobian_Calculator_Func(Joints,T) but you call it ...

7 years ago | 1

| accepted

Answered
How to extract and organize data in a structure?
Where S is your structure, easily using two comma-separated lists: X = [S.label]==1; C = {S(X).message} Read more here: http...

7 years ago | 0

| accepted

Answered
four dimensions array's expression
"Why the third dimension is 1, not (1,2,3)?" Part 1: Indexing Because that is exactly what you told MATLAB to do, when you wr...

7 years ago | 0

Answered
omit same element inside cell
>> A = {[1,2,3,4],[4,2,3],[1,2,5,6,78,9],[1,2,3,4],[1,2,5,6,78,9],[4,2,3],[5,6,7]}; >> N = numel(A); >> X = false(N,N); % find...

7 years ago | 0

| accepted

Answered
concatenate values from matrix and cell array
>> M = [1,2,3;4,5,6;7,8,9]; >> C = {'aa','bb','cc';'dd','ee','ff';'gg','hh','ii'}; >> F = @(n,c) sprintf('%d - %s',n,c{:}); >...

7 years ago | 1

| accepted

Answered
Replace Nan in array with the previous value/text/number
Explanation: you forgot to consider what isnan returns with a non-scalar input (such as when you provide it with those character...

7 years ago | 1

| accepted

Answered
Transfer hh:mm (Time) into "double"
>> str = '10:31'; >> val = [1,1/60]*sscanf(str,'%d:%d') val = 10.51666666666667

7 years ago | 2

| accepted

Answered
Guess my favourite colour!
You will need to: Decide on a colorspace to measure the color differences in: https://en.wikipedia.org/wiki/Color_difference . ...

7 years ago | 0

Answered
rearrange order of a diagonal interaction matrix
Using basic subscript indexing: >> A = [0.2185,0.8995,0.8727;0.8995,0.9230,0.9742;0.8727,0.9742,0.5763] A = 0.21850 0.89...

7 years ago | 0

| accepted

Answered
How do I generate .mat database from an imageset and get defined features from each to from another .mat database?
Unless you actually have more .png files saved in that folder and you only need to select a subset of them, then by far the easi...

7 years ago | 1

| accepted

Answered
How to save vector output from for loop?
Much simpler without a loop: >> A = toeplitz(1:3)+reshape(1:9,1,1,[]) A(:,:,1) = 1 2 3 2 1 2 3 2 1 (:...

7 years ago | 2

Answered
How to I delete every nth value from a 1xN matrix starting with a certain value.
If by "row" you really mean "element": >> Y = [-5,-4,-3,-2,-1,0,1,2,3,4,5]; >> Y(2:3:end) = [] Y = -5 -3 -2 0 1 3 ...

7 years ago | 0

Load more