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

circa 9 anni fa | 0

| accettato

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

circa 9 anni fa | 1

| accettato

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

circa 9 anni fa | 5

| accettato

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

circa 9 anni fa | 0

| accettato

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

circa 9 anni fa | 1

| accettato

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

circa 9 anni fa | 1

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

circa 9 anni fa | 0

| accettato

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

circa 9 anni fa | 0

| accettato

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

circa 9 anni fa | 0

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

circa 9 anni fa | 1

| accettato

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

circa 9 anni fa | 1

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

circa 9 anni fa | 0

| accettato

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

circa 9 anni fa | 0

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

circa 9 anni fa | 1

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

circa 9 anni fa | 0

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

circa 9 anni fa | 1

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

circa 9 anni fa | 0

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

circa 9 anni fa | 3

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

circa 9 anni fa | 0

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

circa 9 anni fa | 0

| accettato

Risposto
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

circa 9 anni fa | 0

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

circa 9 anni fa | 0

| accettato

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

circa 9 anni fa | 2

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

circa 9 anni fa | 0

| accettato

Risposto
roots of septic polynomial
Use 'roots' function.

circa 9 anni fa | 1

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

circa 9 anni fa | 0

| accettato

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

circa 9 anni fa | 0

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

circa 9 anni fa | 1

| accettato

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

circa 9 anni fa | 1

| accettato

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

circa 9 anni fa | 1

| accettato

Carica altro