Risposto
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

oltre 9 anni fa | 1

| accettato

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

oltre 9 anni fa | 0

| accettato

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

oltre 9 anni fa | 2

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

oltre 9 anni fa | 2

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

oltre 9 anni fa | 0

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

oltre 9 anni fa | 0

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

oltre 9 anni fa | 0

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

oltre 9 anni fa | 0

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

oltre 9 anni fa | 0

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

oltre 9 anni fa | 2

| accettato

Risposto
Remove row in numeric data
Dataset = Dataset(1:3:end,:);

oltre 9 anni fa | 0

| accettato

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

oltre 9 anni fa | 0

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

oltre 9 anni fa | 1

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

oltre 9 anni fa | 0

| accettato

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

oltre 9 anni fa | 0

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

oltre 9 anni fa | 1

| accettato

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

oltre 9 anni fa | 0

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

oltre 9 anni fa | 0

| accettato

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

oltre 9 anni fa | 1

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

oltre 9 anni fa | 0

| accettato

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

oltre 9 anni fa | 1

| accettato

Risposto
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

oltre 9 anni fa | 1

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

oltre 9 anni fa | 1

| accettato

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

oltre 9 anni fa | 0

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

oltre 9 anni fa | 0

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

oltre 9 anni fa | 1

| accettato

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

oltre 9 anni fa | 0

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

oltre 9 anni fa | 0

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

oltre 9 anni fa | 0

| accettato

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

oltre 9 anni fa | 0

Carica altro