Beantwortet
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...

etwa 10 Jahre vor | 3

| akzeptiert

Beantwortet
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...

etwa 10 Jahre vor | 0

| akzeptiert

Beantwortet
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); ...

etwa 10 Jahre vor | 0

Beantwortet
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';...

etwa 10 Jahre vor | 0

Beantwortet
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

etwa 10 Jahre vor | 0

Beantwortet
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 ...

etwa 10 Jahre vor | 0

Beantwortet
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...

etwa 10 Jahre vor | 2

Beantwortet
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 = ...

etwa 10 Jahre vor | 0

| akzeptiert

Beantwortet
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...

etwa 10 Jahre vor | 0

| akzeptiert

Beantwortet
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...

etwa 10 Jahre vor | 0

Beantwortet
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 ...

etwa 10 Jahre vor | 0

Beantwortet
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...

etwa 10 Jahre vor | 0

| akzeptiert

Beantwortet
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.

etwa 10 Jahre vor | 2

| akzeptiert

Beantwortet
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,...

etwa 10 Jahre vor | 1

Beantwortet
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;

etwa 10 Jahre vor | 0

| akzeptiert

Beantwortet
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); ...

etwa 10 Jahre vor | 0

| akzeptiert

Beantwortet
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, ...

etwa 10 Jahre vor | 0

Beantwortet
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 ...

etwa 10 Jahre vor | 0

Beantwortet
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...

etwa 10 Jahre vor | 0

| akzeptiert

Beantwortet
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...

etwa 10 Jahre vor | 0

Beantwortet
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));

etwa 10 Jahre vor | 1

Beantwortet
Creating specific matrix from other matrix?
x2 = find(x~=0);

etwa 10 Jahre vor | 0

| akzeptiert

Beantwortet
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'...

etwa 10 Jahre vor | 0

Beantwortet
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...

etwa 10 Jahre vor | 0

Beantwortet
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 ...

etwa 10 Jahre vor | 0

Beantwortet
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...

etwa 10 Jahre vor | 0

| akzeptiert

Beantwortet
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...

etwa 10 Jahre vor | 0

| akzeptiert

Beantwortet
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...

etwa 10 Jahre vor | 1

Beantwortet
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...

etwa 10 Jahre vor | 1

| akzeptiert

Mehr laden