Answered
Reordering data based on a separate cell array
B = {'Si','W','Ou','In','We','Ru','Cy','El','St','Jo', 'In'} % example data Collections = { {'Si','St','W'},{'Ou','Jo','R...

8 years ago | 0

| accepted

Answered
How to place NaN at diagonal position in cell array?
a={[],-1,-1,0.8,-0.7,[],[]; [],[],0.9,1,[],-0.9,0.6; -1,[],[],0.9,0.2,[],0.8} sz = size(a) out = repmat({NaN}, sz + [0 1...

8 years ago | 1

Answered
How to place NaN at diagonal position in cell array?
Put NaNs on the diagonal: tf = eye(size(a))==1 a(tf) = {NaN}

8 years ago | 0

Answered
Move all NaN to end of matrix columns.
10+ years ago, I submitted the function *sortlind* to the Matlab File Exchange, which returns linear indices (rather than sub in...

8 years ago | 0

Submitted


sortlind(A, varargin)
sorts input and returns linear indices for parallel sorting

8 years ago | 1 download |

3.66667 / 5

Answered
difference between normalization -1 to 1 and 0 to 1
The differences include the min, max, range, mean, median, variance, and many more properties of the normalised data.

8 years ago | 0

Answered
exponential fit base 10
Your plot command is incorrect, it seems (f2 is the fit result, not an x-value). So, try this: plot(freq, f2(freq), 'r-') ...

8 years ago | 0

Answered
How to begin axis from another value and make it a 0 point in plot matlab?
1) change the limits plot(x,y) xlim([23 100]) 2) change the data (not recommended) plot(x,y-23)

8 years ago | 1

Answered
convert cell into double with diferent cell sizes
You can my PADCAT function to concatenate vectors with different lengths. It is available at the Matlab File Exchange: <https...

8 years ago | 0

| accepted

Answered
Specify row and column independently to update matrix?
doc sub2ind

8 years ago | 0

| accepted

Answered
how to permute all combinations of this vector??
This is one approach: N = 4 ; [b{1:N}] = ndgrid([0 1]) c = reshape(cat(N+1, ones(size(b{1})), b{:}), [], N+1)

8 years ago | 0

| accepted

Answered
How do I fprintf a title for every third iteration in a loop?
In pseudocode it would look like this: if mod(linecounter,3)==0 print header end print line linecounter = li...

8 years ago | 0

Question


Why are people deleting answers?
Occasionally I see answers being deleted by their authors. This is rather unfortunate, especially if the answer is perfectly val...

8 years ago | 1 answer | 2

1

answer

Answered
NEW MATRIX WITH IF CONDITIONS
No need for loops or ifs: % data D1 = [ 10 20 30 40 50 60] S1 = [ 1 0 0 1 1 0] % engine D2 = zeros(si...

8 years ago | 0

Answered
store the index of nanvalues
% data A = [ 1 2 3 4 3 NaN NaN 5 NaN 7 ] % engines tf = ~isna...

8 years ago | 0

Answered
While all elements are not equal to NaN
*not* (~), *all*, and *isnan* are your friends. If A is your array, while ~all(isnan(A(:))) ... end

8 years ago | 4

| accepted

Answered
Why is my code running for forever?
You never change *n* inside the second while loop → T(n) never changes → *T(n) <= Tmax* always evaluates to true → inf...

8 years ago | 0

Answered
Can matlab return the interval of 1's and 0's?
Given your replies to the comments, you could store the result in a N-by-2 matrix, where the first row would hold the start indi...

8 years ago | 0

| accepted

Answered
Bed of Nails from vectors - inverse of find()?
% input N = 5 ; M = 4 ; a = [1 3 ; 2 4 ; 1 4 ; 1 2 ; 3 4] % engine in one line XX = full(sparse(repmat(1:N, s...

8 years ago | 0

| accepted

Answered
Insert 0s in a column matrix with an if function
Something along these lines? T1 = [1;2;4;6;9;10] B = [1;1;1;1;1;1] T2 = 1:10 A(T2) = 0 A(T1) = B

8 years ago | 0

Answered
Bed of Nails from vectors - inverse of find()?
N = 5 ; M = 4 ; a = [1 3 ; 2 4 ; 1 4 ; 1 2 ; 3 4] X = zeros(N,M) X(sub2ind([N M], repmat(1:N, size(a,2), 1)', a)...

8 years ago | 0

Answered
Grouping rows on the first two columns
A = [13 30 7 13 30 6 13 40 5 13 40 6 12 30 7 12 37 5] ; % engine [B,~,gi] = unique(A(:,[1 2...

8 years ago | 0

| accepted

Answered
Using rows of different files to create a matrix
% Load in the data and store in cells for k=1:6, filename = ... C{k} = MyLoadFile(filename) ; % C{k} is a N-by-...

8 years ago | 0

Answered
How to find the mean intensity of an image greater than a threshold?
IM = rand(100,100) ; % test image threshold = 0.3 tf = IM > threshold RequiredValue = mean(IM(tf))

8 years ago | 0

Answered
error in if else
In Matlab, indexing is done by round brackets, and concatenation by square brackets: A = [1 2 3] B = [A 4 5] % concate...

8 years ago | 0

Answered
How to properly input a range in a vector
A = magic(4) range = ':' % in a variable B = subsref(A,substruct('()',{range, 1})) But i do think there are easier w...

8 years ago | 1

Answered
I have an extra 'ans' I don't want to be shown, how do I remove it?
The ans is the result of your function call without output arguments and no-semicolon >> Ass_3_Question_3b The fact that...

8 years ago | 1

Answered
How to combine two cell arrays of the same size without for loop?
Here is an elegant way: A = {1,2 3 4 5} B = {11,12,13,14,15} C = arrayfun(@(k) [A{k} B{k}], 1:numel(A), 'un', 0) ...

8 years ago | 0

Answered
How to fill cell array with random numbers without for loop?
Your definition of the function is incorrect. To fill a cell array with random numbers: startSeedsX=arrayfun@(@() rand*100,...

8 years ago | 0

| accepted

Answered
How to compute Permutation with repetition, (One Value From Each Vector Only)?
A = [50 60 70 80] ; B = [10 30 90 100] ; C = [100 500 700 1000] ; % get all combinations by taking elements from ...

8 years ago | 0

| accepted

Load more