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

Answered
combine for loop and ~isinf,but there is an error in every loops except the result in the first loop
v = [3,6,1,Inf]; for k = 1:numel(v) n = v(k); z = n(~isinf(n)) end displays: z = 3 z = 6 z = 1 z = [] "i c...

7 years ago | 0

| accepted

Answered
MatLab function for each two values in struct inside loop
load example.mat C = {example.Name}; D = {example.dates}; M = [example.x;example.y]; [U,~,idu] = unique(D); N = max(idu); ...

7 years ago | 2

| accepted

Answered
Finding substring based on another substring
"What is the most efficient way to get files along the diagonal?" Probably something like this is about as efficient as you can...

7 years ago | 0

| accepted

Answered
I need to save columns from n number of matrices into different variables
Rather than forcing yourself into writing badly designed code (like your very inefficient eval usage inside the for loop), you s...

7 years ago | 2

| accepted

Answered
How can i regexp this sample text?
Here is a regexp-based solution which does NOT use hard-coded variable names (it automatically detects the variable names), and ...

7 years ago | 2

Answered
save matfile with current time stamp
Do NOT concatenate paths and filenames! This is the cause of many beginners' bugs, because simple concatenation does not handle ...

7 years ago | 0

Answered
storing the index of an Matrix for non zeros
In just two lines, no loop required: >> X = [1,0,2;0,1,1;0,0,4] X = 1 0 2 0 1 1 0 0 ...

7 years ago | 2

| accepted

Answered
I have a problem with fprintf function, MATLAB
You only defined four number conversions within the format string, but you have provided five inputs to fprintf. Start by writin...

7 years ago | 0

| accepted

Answered
How to fix an error in which the system could not read image from folder under loop, using "dir" function?
If you specify the directory for the dir call then you also need to specify it when you read the file: D = '1folder'; S = dir(...

7 years ago | 0

| accepted

Answered
plotting separate parts of a column on different figures
Following your description "I have a large matrix. In the 3rd column, I have my "eta" values. In my 4th column, I have "r" value...

7 years ago | 1

| accepted

Answered
Compare the number of elements in each row of 2 cell arrays (A and B) and determine which array contains minimum number of elements for that row and save them.
Based on the explanation in your comment: isA = ~cellfun('isempty',A); isB = ~cellfun('isempty',B); csA = cumsum(isA,2); csB...

7 years ago | 2

| accepted

Answered
Sum variable size chunks in array
Avoiding duplicating the data in memory (i.e. avoid mat2cell) will probably be faster for larger matrices: fun = @(c){sum(A(:,c...

7 years ago | 1

| accepted

Answered
Why does it seem that the ~isinf(cvx_optval) and co( ~isinf(cvx_optval)) are both not work
"...so theorically,the real answer should be" co= 1 0 1 Nope. You defined co like this: co(bd) = ... where b...

7 years ago | 0

Answered
Unfold 3D Matrix to 2D
Currently the simplest solution is to just use indexing to get the order you want: >> M = reshape(A,3,[]); >> M = M(:,[8,7,4,1...

7 years ago | 0

Answered
Using array values as indices for inserting values into a larger destination array
Use sub2ind: N = 8; R = randi(9,N); % more interesting than MAGIC. C = randi(9,N); % more interesting than MAGIC. V = reshap...

7 years ago | 0

| accepted

Answered
Indice wise reference of indice from another matrix
Use ndgrid and sub2ind: >> A = [0,1;1,1]; >> D = [1,1;2,3]; >> B = zeros(2,2,3); >> S = size(B); >> [R,C] = ndgrid(1:S(1),1...

7 years ago | 0

| accepted

Load more