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

más de 8 años hace | 0

| aceptada

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

más de 8 años hace | 1

| aceptada

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

casi 9 años hace | 5

| aceptada

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

casi 9 años hace | 0

| aceptada

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

casi 9 años hace | 1

| aceptada

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

casi 9 años hace | 1

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

casi 9 años hace | 0

| aceptada

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

casi 9 años hace | 0

| aceptada

Respondida
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)

casi 9 años hace | 0

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

casi 9 años hace | 1

| aceptada

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

casi 9 años hace | 1

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

casi 9 años hace | 0

| aceptada

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

casi 9 años hace | 0

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

casi 9 años hace | 1

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

casi 9 años hace | 0

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

casi 9 años hace | 1

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

casi 9 años hace | 0

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

casi 9 años hace | 3

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

casi 9 años hace | 0

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

casi 9 años hace | 0

| aceptada

Respondida
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

casi 9 años hace | 0

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

casi 9 años hace | 0

| aceptada

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

casi 9 años hace | 2

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

casi 9 años hace | 0

| aceptada

Respondida
roots of septic polynomial
Use 'roots' function.

casi 9 años hace | 1

Respondida
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:...

casi 9 años hace | 0

| aceptada

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

casi 9 años hace | 0

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

casi 9 años hace | 1

| aceptada

Respondida
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]...

casi 9 años hace | 1

| aceptada

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

casi 9 años hace | 1

| aceptada

Cargar más