답변 있음
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...

대략 10년 전 | 3

| 수락됨

답변 있음
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...

대략 10년 전 | 0

| 수락됨

답변 있음
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); ...

대략 10년 전 | 0

답변 있음
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';...

대략 10년 전 | 0

답변 있음
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

대략 10년 전 | 0

답변 있음
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 ...

대략 10년 전 | 0

답변 있음
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...

대략 10년 전 | 2

답변 있음
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 = ...

대략 10년 전 | 0

| 수락됨

답변 있음
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...

대략 10년 전 | 0

| 수락됨

답변 있음
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...

대략 10년 전 | 0

답변 있음
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 ...

대략 10년 전 | 0

답변 있음
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...

대략 10년 전 | 0

| 수락됨

답변 있음
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.

대략 10년 전 | 2

| 수락됨

답변 있음
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,...

대략 10년 전 | 1

답변 있음
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;

대략 10년 전 | 0

| 수락됨

답변 있음
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); ...

대략 10년 전 | 0

| 수락됨

답변 있음
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, ...

대략 10년 전 | 0

답변 있음
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 ...

대략 10년 전 | 0

답변 있음
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...

대략 10년 전 | 0

| 수락됨

답변 있음
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...

대략 10년 전 | 0

답변 있음
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));

대략 10년 전 | 1

답변 있음
Creating specific matrix from other matrix?
x2 = find(x~=0);

대략 10년 전 | 0

| 수락됨

답변 있음
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'...

대략 10년 전 | 0

답변 있음
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...

대략 10년 전 | 0

답변 있음
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 ...

대략 10년 전 | 0

답변 있음
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...

대략 10년 전 | 0

| 수락됨

답변 있음
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...

대략 10년 전 | 0

| 수락됨

답변 있음
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...

대략 10년 전 | 1

답변 있음
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...

대략 10년 전 | 1

| 수락됨

더 보기