Réponse apportée
How do I code this in a more efficient way?
[m,n] = size(M); M = [zeros(1,n+2);zeros(m,1),M,zeros(m,1);zeros(1,n+2)]; out = 1/2*(M(x+1,y+1)+sum(sum(M(x:x+2,y:y+2...

presque 10 ans il y a | 3

| A accepté

Réponse apportée
Why is this function not recognizing the correct number of rows?
Change the line [R,~]=size(m); to R = 2; You want to do your maximizing along the second dimension, not the fo...

presque 10 ans il y a | 0

| A accepté

Réponse apportée
Finding the max indeces of a 3d matrix and setting all non max indeces to 0
Let M be your 3D array. [n1,n2,n3] = size(M); M = reshape(M,n1*n2,n3); z = zeros(n1*n2,1); I = zeros(n3,1); ...

presque 10 ans il y a | 0

Réponse apportée
How do you write a MATLAB code that returns the indices of the elements that will sum to exactly half of the sum of all elements?
Here's a brute force method: n = length(a); s = sum(a)/2; ai = []; for k = 0:2^n-1 t = dec2bin(k,n)-'0';...

presque 10 ans il y a | 0

Réponse apportée
I need to create all a list of all possible states
A = zeros(2^N,N); for k = 0:2^N-1 A(k+1,:) = 2*(dec2bin(k,N)-'0')-1; end

presque 10 ans il y a | 0

Réponse apportée
how to find irreducible factors of a polynomial
What ring or field can the coefficients of your reduced polynomials belong to? It makes a difference as to their classification ...

presque 10 ans il y a | 0

Réponse apportée
Finding sequences of consecutive 1s
Assume 'n' is a row vector. f = find(diff([false,n==1,false])~=0); [m,ix] = max(f(2:2:end)-f(1:2:end-1)); The value...

presque 10 ans il y a | 2

Réponse apportée
How to remove rows having repeating elements from a matrix?
t = false(1,size(A,1)); for k = 1:size(A,1) u = unique(A(k,:)); t(k) = size(u,2)==size(A,2); end B = ...

presque 10 ans il y a | 0

| A accepté

Réponse apportée
Permutation without using perms, randperm, randsample
The logic in your 'if' part is faulty. When you do the test "find(newArray(i))==d", you are doing a test on a single-element ve...

presque 10 ans il y a | 0

| A accepté

Réponse apportée
using a double or triple for loop?
Jgg is correct that you wouldn't need matlab to do this problem, but if you generalize to have N number of dollars initially ins...

presque 10 ans il y a | 0

Réponse apportée
how can i solve this ?
You could use matlab's 'ldivide' (back-slash) operator. (I assume the first equation was meant to be "-3x1-6x2+2x3=-61.5" with ...

presque 10 ans il y a | 0

Réponse apportée
If the result of subtraction of two values in a image matrix is negative, the value is set to zero.
Very likely your image values are in 'uint8' format, and this is how matlab does its subtraction in that format. To do otherwis...

presque 10 ans il y a | 0

| A accepté

Réponse apportée
Passing through each element in a matrix just once and randomly
B = A(randperm(prod(size(A)))); The vector B will have each value of A once and only once in random order.

presque 10 ans il y a | 2

| A accepté

Réponse apportée
Largest three digit number in Matlab?
Following Walter's idea, if the number must be exactly representable I propose: 8^(2^8) If it doesn't have to be exact,...

presque 10 ans il y a | 1

Réponse apportée
if i have tow matrix how to crossover of them ?
R = repmat(randi([0,1],4,1),1,4); C1 = A.*R+B.*(1-R); C2 = A.*(1-R)+B.*R;

presque 10 ans il y a | 0

| A accepté

Réponse apportée
I need Random many numbers
If you mean random integers, R = randi([0,255],65000,1); If you mean random real numbers, R = 255*rand(65000,1); ...

presque 10 ans il y a | 0

| A accepté

Réponse apportée
Why does MATLAB returns a different value when we use a function?
As you may be aware, in neither double precision nor single precision floating point format numbers such as you are using here, ...

presque 10 ans il y a | 0

Réponse apportée
how to add column of a matrix
b = zeros(4,16); for k = 0:15 t = double(dec2bin(k,4)-'0'); b(:,k+1) = sum(bsxfun(@times,a,t),2); end ...

presque 10 ans il y a | 0

Réponse apportée
Simpson's Rule
I think you made an error on the line for j = 1:n-1 It should be for j = 1:k-1 where k = n/2. As it stands n...

presque 10 ans il y a | 0

| A accepté

Réponse apportée
computing the infinite sum
It is my opinion that this problem would require something other than adding the given terms out sufficiently far for 14-digit a...

presque 10 ans il y a | 0

Réponse apportée
How do I do greater than and less than in the same command then find the size?
This is very elementary matlab. Assuming 'mag' is a vector, do this: count = sum((7<=mag)&(mag<=8));

presque 10 ans il y a | 1

Réponse apportée
Creating specific matrix from other matrix?
x2 = find(x~=0);

presque 10 ans il y a | 0

| A accepté

Réponse apportée
How can I separate these graphs?
You have given 'plot' a 201 x 5 matrix, F1, to be plotted against a 201 x 1 column vector, x'. Under those circumstances 'plot'...

presque 10 ans il y a | 0

Réponse apportée
How to find standard deviation based on the mean and a point on the line?
If you mean that you have a single point on some valid Gaussian density distribution curve (and not just a sample) then two poss...

presque 10 ans il y a | 0

Réponse apportée
Simultaneously fitting three equations to get model parameters?
You apparently have just one equation, namely "Ratio1+Ratio2+Ratio3=3", and two unknowns, A and B. In general such a situation ...

presque 10 ans il y a | 0

Réponse apportée
Compute the acuarcy or error of the output?
Ymodel = 1*(Y>.5) + 0*(Y<=.5); % The model from the predictions (right half unnecessary) p = sum(abs(Y-Ymodel))/size(Y,2...

presque 10 ans il y a | 0

| A accepté

Réponse apportée
Normalizing columns of a matrix
Assume by "norm" you mean the usual 2-norm, and that your 10000 x 10000 matrix is named 'M'. n = sqrt(sum(M.^2,1)); % Comp...

presque 10 ans il y a | 0

| A accepté

Réponse apportée
Help ! two nonlinear equations
This doesn't solve your equations, but you can gain a better insight into their nature by expanding the cosine expressions in te...

presque 10 ans il y a | 1

Réponse apportée
Random numbers from complex PDF
The probability of lying inside a circle about the center with radius R in the X-Y plane is P = 1-exp(-R^2/(G-1)) Theref...

presque 10 ans il y a | 1

| A accepté

Charger plus