Answered
How can I find the roots of only one equation using fsolve?
Do a plot of h versus z for a sufficiently large positive range of z and make an estimate of the z location of the first zero cr...

10 years ago | 0

Answered
To find the number of sections with negative values
Let x be the third column of your data matrix. f = find(diff([false;x<0;false])~=0); ns = length(find(f(2:2:end)-f(1:2...

10 years ago | 0

Answered
how to find the manhattan distance between 2 matrices of defferent size
I would assume you mean you want the “manhattan distance”, (otherwise known as the L1 distance,) between p and each separate row...

10 years ago | 0

| accepted

Answered
How to repeat rows of a matrix sequentially?
Let your present 24 x 1 column vector be called x. x2 = reshape(repmat(x.’,20,1),[],1);

10 years ago | 0

Answered
matrix column multiplication with rows of another matrix
Let M be your 15 x 15 matrix and A be your n x 3 matrix. B = zeros(size(M,1),3,size(A,1)); % A three-dimensional result ...

10 years ago | 0

Answered
How can i get this function to display (0,0,0) when it goes through a,b and A being assigned values more than once?
As you originally stated this problem, Cameron, P was to be the integer perimeter of an isosceles triangle, a an integer length ...

10 years ago | 0

Answered
calculate the probability of comparation of two variables
If f1(x) is the probability density of one distribution and f2(y) a second one, and if they are independent, the probability tha...

10 years ago | 0

| accepted

Answered
How can I find radius of any valley/peak of a signals?
The general formula for the curvature of a function y = f(x) is: K = ±d2y/dx2/(1+(dy/dx)^2)^(3/2) where the sign ambigu...

10 years ago | 0

Answered
How to draw a log function?
The quantity f(log10(f(x)) does not yield the solution to log10(y) = 1 + log10(x). It is actually equal to f(log10(f(x)) ...

10 years ago | 0

Answered
Can someone help me with my if statements in my function?
Your test “IntTestP==0” does not accomplish what you think it does. The only way “fix((fix(P)-P)+1)” can be zero is for P to be...

10 years ago | 0

Answered
How to write this matrix better?
k = 1e6*(diag(s(1:22),1)+diag(s(1:22),-1)+... diag(-[s(1:22),0]-[0,s(1:22)])); I am assuming s is a row vecto...

10 years ago | 0

| accepted

Answered
Create a new matrix of the old matrix
[m,n] = size(A); B = zeros(m,n+m-1); [I,J] = ndgrid(1:m,1:n); B(I+m*(J-I+m-1)) = A(I+m*(J-1));

10 years ago | 1

| accepted

Answered
How to make one element in a matrix the same for other elements?
You want every other element in the second row to be set equal to the first element? A(2,:) = A(2.1); Or do you have ot...

10 years ago | 0

Answered
How can i select random sample from mixture of two normal distributions in MATLAB ?
r = rand(100,1)>=.05; R1 = normrnd(0,sqrt(25),100,1); R2 = normrnd(0,sqrt(1),100,1); S = (1-r).*R1+r.*R2; S co...

10 years ago | 2

| accepted

Answered
Displaying a more precise answer when using diff()
In your code you have asked for the derivative of the constant 1, and of course its derivative will be zero. You need to find t...

10 years ago | 0

| accepted

Answered
How to create a corresponce between 2 column vector? (Replicating the vlookup funcion of excel)
[L,ix] = ismember(C,A); D = B(ix(L));

10 years ago | 0

| accepted

Answered
Hello everyone, i tried to understand and implement the sum product algorithm with following examples . can someone help me to implement this in matlab coding?
The code is wrong in the innermost loop. I believe it should be: for ii=1:4 if H(ii,j)==1 && i~=ii mul=mul*...

10 years ago | 0

| accepted

Answered
Hello Everyone, I have a Matlab problem related to random combinations of number and it goes like this:
Specifying covariance values between random variables does not necessarily determine their joint probability distributions. For...

10 years ago | 0

Answered
How many times this for loop will execute
As to the “why” the for-loop does not accept any changes you might make to its variable, in this case ‘i’, as it repeats. So ev...

10 years ago | 0

Answered
Nearly identical code, hugely different runtimes
The progress of your routine will be extremely sensitive to the value you give to ‘rmax’ in the one code or ‘moldia’ in the othe...

10 years ago | 0

Answered
Cross Product multi Dim data
Actually you can use matlab's 'cross' function. A = cat(4,u1,v1,w1); % Combine the three components in the 4th dimension ...

10 years ago | 0

| accepted

Answered
How can i speed up the following?
You can turn this into ordinary matrix multiplication. Since matlab is specially optimized for matrix multiplication, it might ...

10 years ago | 1

| accepted

Answered
How to find the number consecutive elements in each row of a matrix?
I will give a method for a single row of integers. Let x be such a row. n = sum(diff(x)==1); That should be the number...

10 years ago | 0

Answered
If statement with 2 commands
Your code should be: if DMS(1,3) == 60 DMS (1,2) = DMS (1,2) + 1; DMS(1,3) = 0; end The '&' operator is...

10 years ago | 0

| accepted

Answered
I've written a simple code in matlab. It worked a few times, but then later started showing "surf error". What could be the reason? I am not an expert in coding or matlab.
Well quite obviously somewhere along the line your 'a' matrix has suddenly become other than 44 x 44 in size. Your task will be...

10 years ago | 0

| accepted

Answered
Calculating the percentage of numbers in my matrix
P = sum(A(:)<10)/numel(A)*100;

10 years ago | 0

| accepted

Answered
is there anything wrong with my function? MATRIX
You've written the code for v1 and v2 incorrectly. It should be: v1 = MatrixA*x1-VectorB; v2 = MatrixA*x2-VectorB; ...

10 years ago | 0

Answered
Rounding numbers using a condition?
Let the "numbers ranging from 95 to 116" be in a row vector u, and the numbers 99, 104, and 115 be in a column vector v. [...

10 years ago | 1

| accepted

Answered
How to generate a matrix G from 3 different square matrices?
Where you wrote: for i=r1+1:1:r2 for j=c1+1:1:c2 G(i,j)=B(i-2,j-2); end end should have been wr...

10 years ago | 0

| accepted

Answered
Count the length of repeated value sets in an array?
f = find(diff([false,x==1,false])~=0); L = f(2:2:end)-f(1:2:end-1);

10 years ago | 0

Load more