Réponse apportée
Counting the Same Occurance of a row string
A solution with less calls to unique: P = {'ADS','µSOIC8';'AVX','0603';'AVX','0603';'AVX','0603';'ELN','';'EPC','0603';'EPC','0...

plus de 5 ans il y a | 0

Réponse apportée
Randomly select an element from a vector satisfying a condition
This is a two-step process: create an intermediate array with all elements of X satisfying your condition select a single elem...

plus de 5 ans il y a | 0

Réponse apportée
Count the adjacent same elements in a vector
This is call run-length encoding, for which you can find excellent function on the File exchange. For instance, [shameless self ...

plus de 5 ans il y a | 1

Réponse apportée
I am supposed to get list of matrices but I am getting this.What do they mean?
Your variable is a cell array, which is a very useful and common way to store things in matlab. Read more on cell arrays in the ...

plus de 5 ans il y a | 1

Réponse apportée
Storing Matrices from a for loop
One option is to use an index to loop over the values, like this. You can than directly use that index to create a cell array to...

plus de 5 ans il y a | 1

| A accepté

Réponse apportée
Using the switch statement inside the for loop.
I suggest you try to avoid a switch statement inside the for-loop as this will probably slow down things a lot. Depending on wha...

plus de 5 ans il y a | 0

Réponse apportée
2-x axes and 1-y axis
What about 'abusing' plotyy? x = 0:0.01:20; y1 = 200*exp(-0.05*x).*sin(x); y2 = 0.8*exp(-0.5*x).*sin(10*x); plotyy(x, y1, x,...

plus de 5 ans il y a | 0

Réponse apportée
Plotting a series for n>=1
I suggest you avoid meshgrid here. Another tip is to rewrite your function to a somewat simpler form, so you do not loose track ...

plus de 5 ans il y a | 0

Réponse apportée
Find out if X out of Y elements of an array are true
Let TF be your logical array and X the index of the last updated element then ConditionIsMet = TF(x) && sum(TF) == 4 will be t...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
matrix with mixed data ?
A table is the most obvious choice for this, especially if you want to do statistics. I suggest you read the manual on tables.

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
requirement Switch & Case expression with matrix
I suggest you use ISMEMBER with the rows option, rather than if-else (or switch) fieldlist = [x3 y3 ; x1 y1 ; x2 y2] ; filed...

plus de 5 ans il y a | 0

Réponse apportée
analyze Consecutive points in an array
Let x be your vector. MyFun = @(i) x(i)>=0.2 && x(i+1)>=0.2 && x(i+2)>=0.2 && x(i-1)<0.2 && x(i-2)<0.2 % MyFun(k) will return ...

plus de 5 ans il y a | 1

| A accepté

Réponse apportée
Transform NaN into number
This function recursively looks at all fields of the structure and replaces any NaNs by a value. Also works for structure arrays...

plus de 5 ans il y a | 1

A soumis


RANDPERMFULL
RANDPERMFULL (N) returns a random derangement (complete permutation) of the integers from 1 to N

plus de 5 ans il y a | 1 téléchargement |

Thumbnail

Réponse apportée
cell2mat conversion
Do you want to convert the 1-by-28 cell array C, each cell holding a 10-by-25 double matrix to a 3D double array M of size 10-by...

plus de 5 ans il y a | 0

Réponse apportée
Follow up: How can I merge two different tables using the first column in common?
% data, (showing the drawback of storing relates things in different variables) A = [1 7; 3 15] B = [2 9; 5 10] ...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
Any small program that is also really cool?
Take a look at the function why.m >> type why

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
Error in the for loop or equality sign
Welcome to the world of floating point arithmetic, where if 0.1+0.2 == 0.3 disp('0.1+0.2 equals 0.3') else disp('0.1...

plus de 5 ans il y a | 1

Réponse apportée
is there any way to replace this code part with an equivalent part that runs faster?
help cumsum

plus de 5 ans il y a | 0

Réponse apportée
Combination of X and Y vectors to get all possible positions on a Cartesian plane
For two vectors, x and y, this might be faster than ndgrid (not tested) xy = [repelem(x(:), numel(y), 1) repmat(y(:), numel(x),...

plus de 5 ans il y a | 0

Réponse apportée
Adding Zeroes and Ones into a Vector
Inserting elements at specific locations is not trivial. Years ago I wrote a function INSERTROWS that does this https://uk.math...

plus de 5 ans il y a | 1

Réponse apportée
constructing symatrical matrix out of vector
v = [1, 2*6, 2*7, 2*8, 2*9, 2, 2*10, 2*11 2*12, 3, 2*13, 2*14, 4, 2*15, 5] % | % I ass...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
How to find first '1' in every row
Not better than using max (for this type of input), but just to show you an alternative: A = [ 0 0 0 0 0 0 1 1 1 1 0 0; 0 0 0 ...

plus de 5 ans il y a | 1

Réponse apportée
How writing code sum 1+2+3+4+...+n
or know your math classics ... n = 120345428372 s = n*(n+1)/2 % sum(1:n) will fail!

plus de 5 ans il y a | 1

Réponse apportée
How to output random number each time a for loop repeats?
You can use an extra variable to keep track of the letters that were guessed correctly. InputString = 'hello' N = numel(InputS...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
a question on for loop statement
This is filtering. T=10; % smaller example k=0.1; u=rand(T,1); % your loop -> a a = zeros(T,1); a(1) =u(1)+ k*0.01; ...

plus de 5 ans il y a | 3

Réponse apportée
Select random data from a matrix and replace it
Here is another, indexing, approach: A = randi(2, 6, 8)-1 % random 0/1 array M = 3 % max number of 1's per column szA = s...

plus de 5 ans il y a | 1

Réponse apportée
Create a Cell Array of Vectors populated with ones
repmat also works for cell arrays C = repmat({nan(1, 200)}, 10, 3)

plus de 5 ans il y a | 1

| A accepté

Réponse apportée
filling a matrix with a loop
% clever indexing trick A= [1 1 0 1] N = 10 ; % smaller example! 400 in your case X = triu(toeplitz(1:N)) ; X(X > numel(A)) ...

plus de 5 ans il y a | 0

A soumis


PERMPOS
all possible ordered permutations of M values in N positions

plus de 5 ans il y a | 1 téléchargement |

Thumbnail

Charger plus