回答済み
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

| 採用済み

さらに読み込む