답변 있음
Can someone help me with a question to do with sequences and creating a function file that find n terms of sequence
a = a_0 + cumsum(3:3:3*n); % The sequence of first n terms s = sum(a); % The sum of these

9년 초과 전 | 1

| 수락됨

답변 있음
Mean of Multiple Matrixes
m = (z1+z2+z3+z4+z5+z6+z7+z8+z9)/9; % The mean of each element

9년 초과 전 | 0

| 수락됨

답변 있음
how ı can calculate area and volume ıf have 4 Coordinates like (x1,y1) (x2,y2) (x3,y3) (x4,y4)
Abdul, I will modify your question a little, since the volume of 2D objects is always zero. Instead let it be this: Calculate t...

9년 초과 전 | 2

답변 있음
How to vectorize a specific for-loop
You might try the ‘hankel’ function: n = numel(text); nk = n-k+1; pattern = hankel(text(1:nk),text(nk:n));

9년 초과 전 | 2

답변 있음
loop runs infinitely,
Oops! I've done something wrong and seemingly erased both my answer and Jan Simon's. I don't know how to correct it, but a tho...

9년 초과 전 | 0

답변 있음
Subscripted assignment dimension mismatch error in valsx. How do I get rid of the error?
It is impossible to be sure about the cause of your error because you haven’t defined the nature of your various variables. How...

9년 초과 전 | 0

답변 있음
Coding to Plot Ellipse
As you have written the parametric equations, for ϕ equal to zero you have a circle traced out with varying T. As ϕ increases, ...

9년 초과 전 | 0

답변 있음
I want to generate a random number between 1 and 10, but I want the chance of a 10 to be greater
For n draws, do this: r = rand(n,1); card = ceil(18*r-10*(r-1/2).*(r>=1/2)); There will be a fifty percent chance o...

9년 초과 전 | 0

답변 있음
Solving a single non-linear equation
It is likely that ‘solve’ is unable to find v as a function of x, as is so often the case, so you would then need to use ‘fzero’...

9년 초과 전 | 0

답변 있음
Is there any way of joining these two for loops into one?
You don’t need any for-loops at all. Do this: A([1:K,n+1-K:n],:,:) = B([1:K,n+1-K:n],:,:); If you insist on one loop, ...

9년 초과 전 | 2

| 수락됨

답변 있음
Remove row in numeric data
Dataset = Dataset(1:3:end,:);

9년 초과 전 | 0

| 수락됨

답변 있음
Swapping a range of points in a matrix
If you prefer one-liners, try this, (again calling your matrix M): M([6:10,(1:5)+size(M,1)]) = M([(1:5)+size(M,1),6:10]); ...

9년 초과 전 | 0

답변 있음
Uninterrupted segment length?
f = find(diff([false,Indexes==2,false])~=0); output = f(2:2:length(f))-f(1:2:length(f));

9년 초과 전 | 1

답변 있음
How to vectorize random permutation of data
You wish to randomly permute each of the rows of ‘data’. Then do this: (Simplified) [m,n] = size(data); [~,p] = so...

9년 초과 전 | 0

| 수락됨

답변 있음
Swapping a range of points in a matrix
Suppose your matrix is called ‘M’. T = M(6:10,1); M(6:10,1) = M(1:5,2); M(1:5,2) = T;

9년 초과 전 | 0

답변 있음
how can i extend a matrix with columns of random entries under the condition that the 3 randomn numbers in column 1-3 sum up to 1?
I wrote a function for the file exchange called ‘randfixedsum’ which will accomplish the task you have in mind. It will generat...

9년 초과 전 | 1

| 수락됨

답변 있음
Solve equation that contains sum analitically
With an appropriate use of the 'symsum' function, you can transform the summations in your expression into one without summation...

9년 초과 전 | 0

답변 있음
How Can I replace the following for loop by vectorization?
Here's a single line code, but I'm not sure it's faster than, or even as fast as, your two nested for-loop solution: Cor...

9년 초과 전 | 0

| 수락됨

답변 있음
Can someone help me graph this function
X = -2*a:.001*a:2*a; Y = -2*b:.001*b:2*b; Z1 = c*sqrt(1+X.^2/a^2+Y.^2/b^2); Z2 = -c*sqrt(1+X.^2/a^2+Y.^2/b^2); ...

9년 초과 전 | 1

답변 있음
Solve not working: Cannot find explicit solution
What you have are two simultaneous equations in two unknowns. The function ‘solve’ must receive both of the equations together ...

9년 초과 전 | 0

| 수락됨

답변 있음
Problem to delete rows in my matrix
The problem here is that you are reducing the row count of ‘res’ whenever you get a successive pair in column 3 that match. Hen...

9년 초과 전 | 1

| 수락됨

답변 있음
How do I pull data from two different matrices to form a new matrix?
p = repmat(I==1,1,10); <-- Corrected D = p.*D1+(1-p).*D2; % <-- The desired result

9년 초과 전 | 1

답변 있음
Can anybody help me understanding this mentioned line of code?
The numerator is the Laplacian under the assumption that there is unit distance spacing between adjacent grid points of the pres...

9년 초과 전 | 1

| 수락됨

답변 있음
How to multiply values to specific elements in a matrix?
Assuming the number of ones in A is equal to the length of B, At = A.’; At(At==1) = B; A = At.’;

9년 초과 전 | 0

답변 있음
Find eigenvalues without the function eig
The eigenvector/eigenvalue problem for a square matrix A tries to solve the problem: (A-s)*v = 0 where ’s’ is an approp...

9년 초과 전 | 0

답변 있음
Create new matrix by deleting columns with negative numbers from old matrix
M = A(:,all(A>=0,1));

9년 초과 전 | 1

| 수락됨

답변 있음
How to change matrix values in matlab without loop
Assume A is n by n in size. A((1:n)+n*(0:n-1)) = a^2; A(n*(1:n)-(0:n-1)) = 2*a Note: If n is odd, the two diagonals...

9년 초과 전 | 0

답변 있음
Eigenvalues and Eigenvectors Question
The ‘eig’ function “[v,d] = eig)A)” is a solution to the equation A*v = v*d where ‘d’ is a diagonal matrix and if possi...

9년 초과 전 | 0

답변 있음
How to switch two values in a matrix?
If I understand the method in your example correctly, then using your definition of x and c, the following should accomplish the...

9년 초과 전 | 0

| 수락됨

답변 있음
How can I move in a matrix from right to left and up and down?
Let A be your matrix. r = 1; % Start at first row S = [zeros(1,size(A,2)-1),r]; % <-- For saving row positions for c ...

9년 초과 전 | 0

더 보기