Réponse apportée
Columns with at least one zero element
Let M be your mxm matrix: tf = any(M==0,1) % true for columns with at least 1 zero C = M(:,~tf) % columns with no zeros

presque 12 ans il y a | 1

Réponse apportée
How to repeat the rows of a matrix by a varying number?
A = [2 1; 3 4; 5 6; 8 2] B = [1;2;4;1] C = cell2mat(arrayfun(@(k) A(repmat(k,B(k),1),:), 1:size(A,1), 'un', 0).')

presque 12 ans il y a | 0

| A accepté

Réponse apportée
How to use for loop to get the minimum number in an array
A = [ 11 7 10 9 6 4 3] B = 8 result = min([A B]) % or if you insist on using a for-loop (why?) result ...

presque 12 ans il y a | 0

| A accepté

Réponse apportée
Error using handle.handle/set
Your does work properly here (although it doesn't show anything useful …) Did you try to use the debugger? What is the conten...

presque 12 ans il y a | 0

Réponse apportée
Sorting the connected component
Use transpose [L, num] = bwlabel(transpose(f)) L = transpose(L) % or use the .' notation to transpose

presque 12 ans il y a | 1

Réponse apportée
How to rename variables in a loop?
*DO NOT DO THIS!* The usefulness of variables is that their contents change during execution of a piece of code, not their names...

presque 12 ans il y a | 0

Réponse apportée
Find multiple elements in an array.
Use the second output of ismember: a = [4 3 1 2 5] b = [2 3 3] [tf, loc] = ismember(b,a) % loc is [ 4 2 2]...

presque 12 ans il y a | 12

Réponse apportée
Sum every i-th column in matrix seperately
sumColsC = sum(C,1) NotInteresting = sumColsC == 0 | sumColsC == size(C,2) sumColsC(NotInteresting) = []

presque 12 ans il y a | 0

Réponse apportée
How total of column of a matrix can be kept be same????
This is called a normalisation procedure. A = rand(10,6) % some random data sumA = sum(A,1) % unequal column sums ...

presque 12 ans il y a | 1

| A accepté

Réponse apportée
how to substitute a row vector to a column of a matrix
a = [1 2 3 4; 5 6 7 8; 9 10 3 4] b = [4 5 7] c = a % copy a c(:,2) = b(:) % transform ...

presque 12 ans il y a | 4

| A accepté

Réponse apportée
How do I extract subscript numbers from a matrix element?
help find V = sparse(rand(5)>.5) [x,y] = find(V) plot(x,y,'b.') and take a look at help spy spy...

presque 12 ans il y a | 0

Réponse apportée
Defining a matrix of moving constants using a loop
A = 1:5 n = 4 B = triu(toeplitz(A, [A zeros(1,n)]))

presque 12 ans il y a | 2

Réponse apportée
How do I measure mean of every 10 data of a vector size 1x1500?
% DATA A = rand(1,1500) ; N = 10 ; % ENGINE M = accumarray((floor((0:numel(A)-1)/N)+1).',A(:),[],@mean) ; ...

presque 12 ans il y a | 0

Réponse apportée
Extend a vector by extending its elements
A fast and also nice alternative: X = [10 ; 20 ; 30 ; 40] d = 3 Y = X(ceil((1:d*numel(X))/d))

presque 12 ans il y a | 0

Réponse apportée
Extend a vector by extending its elements
A slower but nice alternative to repmat: X = [10 20 30 40] d = 4 Y = kron(X, ones(1,d))

presque 12 ans il y a | 0

Réponse apportée
add a column between tow columns
% DATA A = [1 2 3 ; 4 5 6] % original matrix x = [8 ; 9] % values to insert J = 2 % insert x AFTER column J i...

presque 12 ans il y a | 0

Réponse apportée
Reduce dimensionality using indices
Convert sub indices into linear indices: % some data A = ceil(10*rand(3,4,3)) % A has an arbitrary size d = ceil(...

presque 12 ans il y a | 1

| A accepté

Réponse apportée
Sum of the elements of rows of matrix
You do not want to store the results in separate variables R1, R2, etc., but rather as elements of a single variable R, with R(1...

presque 12 ans il y a | 0

Réponse apportée
How do i add all the values which i get using eval function?
*Avoid EVAL !!!* You do not want to store a series of related values in separate variables f1 = .. f2 = .. but rather in a...

presque 12 ans il y a | 1

| A accepté

Réponse apportée
Different length array comparison and replacements
Add a break in the if so the function will break out of the inner-loop, and moves on to the next element of A: help break ...

presque 12 ans il y a | 0

| A accepté

Réponse apportée
Ignoring If statements error
the expression A < B < C will be interpreted in matlab as * 1 < C, when A is smaller than B, or * 0 < C, when A is ...

presque 12 ans il y a | 0

| A accepté

Réponse apportée
Generate automatically vectors of precise length and given values
No need to create an intermediate vector with repmat that could be much longer than the final one. Just use simple indexing into...

presque 12 ans il y a | 1

Réponse apportée
How to generate an array alternating the values of two others?
A = [1 2 3 4 5 6]; B = [10 20 30 40 50 60 70 80 90 100 110 120 130 140 150]; % in steps N = max(numel(A),numel(B...

presque 12 ans il y a | 2

Réponse apportée
series with empty entrys
Each element in a double array has to be set to something. _It cannot be empty._ You can use NaN (or maybe also zero) as a pl...

presque 12 ans il y a | 0

Réponse apportée
Removing values from a variable.
What are the exact criteria for removal? Just when the second column of A{1} matches the second value of B{1} and the third colu...

presque 12 ans il y a | 0

Réponse apportée
plotting marker at partcular index
I might have misinterpreted your question ... To plot a marker at a particular index of a list of (x,y) values, try this exam...

presque 12 ans il y a | 0

| A accepté

Réponse apportée
Is there a way to suppress command outputs to command window?
You can create a function in the current directory or top directory of the path called disp.m and put the following single line ...

presque 12 ans il y a | 3

Réponse apportée
how to prin only integer value in matlab ?
Is this only for display purposes? x = 1/7 disp(x) disp(fix(x)) disp(floor(x)) disp(num2str(x,'%.0f')) ...

presque 12 ans il y a | 0

Réponse apportée
Assigning a vector to multiple rows of a matrix
Indeed, it looks a little ugly. However, using repmat is not that slow. Another, little uglier, but slightly faster and more str...

presque 12 ans il y a | 1

Charger plus