답변 있음
find corresponding elements in a vector
A general approach: If the number of elements is n for both U and V, you can easily construct an n-by-n logical matrix, L, in...

거의 9년 전 | 0

| 수락됨

답변 있음
Solving matrix with some known column values
By your assumption, for any i for which x(i) is already known, the corresponding coefficient A(i,i) will be unknown, while all A...

거의 9년 전 | 1

| 수락됨

답변 있음
Find intersection point of two lines when I have their coordinates ?
The result of the three steps I mentioned would be: xy = [x1*y2-x2*y1,x3*y4-x4*y3]/[y2-y1,y4-y3;-(x2-x1),-(x4-x3)]; I do...

거의 9년 전 | 5

| 수락됨

답변 있음
How can I calculate the angle between two surfaces?
The command [Nx,Ny,Nz] = surfnorm(Z) will return surface normals to surface Z. See: https://www.mathworks.com/help...

거의 9년 전 | 0

| 수락됨

답변 있음
A substitute for this 'for' loop
It is important for efficiency’s sake that you initially allocate a sufficient amount of space for the w1 array before entering ...

거의 9년 전 | 1

| 수락됨

답변 있음
How to find the points furthest from a linear regression line?
If by “furthest” you mean furthest in a direction orthogonal, (rather than vertical,) to your regression line, then do the follo...

대략 9년 전 | 1

답변 있음
Matrix calculation without a For loop
Given the assumption that A is 1 by N, do this: C = A(:)*A; D = bsxfun(@plus,A(:),A)./C;

대략 9년 전 | 0

| 수락됨

답변 있음
Pythagorean triples up to Z without loops
Instead of ‘meshgrid’ I would suggest using ‘ndgrid’: [a,b,c] = ndgrid(1:Z); A = [a(:),b(:),c(:)]; t = A(:,1).^2+A...

대략 9년 전 | 0

| 수락됨

답변 있음
how to plot Zakharov function? Can anyone help me pls
[X1,X2] = meshgrid(linspace(-10,10,81)); T = .5*1*X1+.5*2*X2; Z = X1.^2+X2.^2+T.^2+T.^4; surf(X1,X2,Z)

대략 9년 전 | 0

답변 있음
I am trying to find the number of nonzero elements I have in a matrix without using the nnz function.
If M is your matrix do this: s = sum(M(:)~=0);

대략 9년 전 | 1

| 수락됨

답변 있음
How to fix this error 'Error using xor Matrix dimensions must agree'?
Your a1 and a3 arrays would have different numbers of columns unless the ‘c’ value is exactly half of size(BW,2), so an ‘xor’ op...

대략 9년 전 | 1

답변 있음
how to group data points in matrix
Assuming all numbers in X lie between 0 and 40, and that X is a column vector as indicated in your description, then do: co...

대략 9년 전 | 0

| 수락됨

답변 있음
Nonlinear Tangent (trigonemetric) equation
You are not using 'fzero' correctly. It cannot use a function handle that produces a vector as yours does - in addition to a ch...

대략 9년 전 | 0

답변 있음
How can I access the previous index of a vector?
You don’t appear to use ‘Xint’ for any other purpose than deciding whether to use integers or reals. Therefore I suggest you ch...

대략 9년 전 | 1

답변 있음
how to find the end of major and minor axis of an ellipsoid
I will make some assumptions about the ellipse you describe: # The ‘a’ and ‘b’ values are the lengths of the ellipse’s semi-m...

대략 9년 전 | 0

답변 있음
Build my own AND function
Your code doesn't achieve the 'and' function. In the case when both a and b are false, the valid 'and' result should be false, ...

대략 9년 전 | 1

답변 있음
Im not sure how to tackle this error message, can anyone help?
The trouble is just as the error message states. On the left side of x(i+1) = ((33.5*x.^0.48)-4.768)/53.246; you are t...

대략 9년 전 | 0

답변 있음
cube root of negative numbers gets complex numbers? Is it a bug?
It's not a bug. That complex value is one of the three valid cube roots of -8. If you want to get the real -2 value, use the '...

대략 9년 전 | 3

답변 있음
generate y(n)=y(n-1)+x(n)
That is precisely what the matlab ‘cumsum’ function does: y = cumsum(x);

대략 9년 전 | 0

답변 있음
To make vector compatible to matrix.
If Data.y is a vector, to make the matrix multiplication H'*Data.y valid, it must be a column vector with the same number of ele...

대략 9년 전 | 0

| 수락됨

답변 있음
How can i position the minimum value in the first cell for each column, without changing the sequence?
[~,I] = min(A,[],1); for k = 1:size(A,2); A(:,k) = circshift(A(:,k),1-I(k),1); end

대략 9년 전 | 0

답변 있음
Is that possible to take numerical integration over a semi-definite integral?
If a symbolic solution cannot be found for the inner integral, you can use the matlab function ‘integral2’ for your task. If yo...

대략 9년 전 | 0

| 수락됨

답변 있음
How to replace the diagonal elements of a matrix with 0 fro avoiding self loops?
If your matrix M is not square and if you only want those diagonal elements changed to zero “if it is 1”, then you can do the fo...

대략 9년 전 | 2

답변 있음
How do you add specific elements contained within a matrix to produce a new vector?
That's known as convolution, and you can use matlab's 'conv' function to do the required computation. w = conv(x,h); w =...

대략 9년 전 | 0

| 수락됨

답변 있음
roots of septic polynomial
Use 'roots' function.

대략 9년 전 | 1

답변 있음
How can I calculate all of the possible combinations of two 1x6 vectors?
V = [V1;V2]; n = size(V,2); p = dec2bin(0:2^n-1,n)-‘0’+1; M = zeros(size(p)); for k = 1:size(p,1); for m = 1:...

대략 9년 전 | 0

| 수락됨

답변 있음
using finite differences to estimate the second derivative of cosh(2x)
I see some things that are haywire. 1. You haven’t defined x in time for use with ‘f’ - it is only defined inside the for-l...

대략 9년 전 | 0

답변 있음
How can I create a loop that iterates thru +/- values of an array to find a solution?
If ‘data’ is a row vector and ‘summ’ is the desired sum, do this: n = length(data); d = dec2bin(0:2^n-1,n)-‘0’; d = r...

대략 9년 전 | 1

| 수락됨

답변 있음
How to find the centroids and the angle between each of them?
Once you know the centroids as x-y coordinates, it is easy to find their distances and angles. Suppose A = [x1,y1], B = [x2,y2]...

대략 9년 전 | 1

| 수락됨

답변 있음
How to draw random number from a Cauchy Distribution
To generate N random values of x with a Cauchy distribution where b is the half width at the half maximum density level and m is...

대략 9년 전 | 1

| 수락됨

더 보기