답변 있음
Using binornd function - problem with draw variability
By writing “binornd(1,p)” you are restricting yourself to the values 0 and 1 with probabilities 1-p and p. To get a larger rang...

대략 10년 전 | 0

답변 있음
How does randperm with 2 arguments work internally?
[~,p] = sort(rand(n,1)); p = p(1:k); where p contains k unique values chosen from 1:n. Of course Mathworks may well u...

대략 10년 전 | 0

답변 있음
Help please - How to extract row and column from matrix from certain value
[row,col] = find(M==1048); where M is your matrix.

대략 10년 전 | 0

답변 있음
Add a number of zeros to matrix row depending on its content.
V = zeros(max(A),1); V(A) = 1; B = diag(V);

대략 10년 전 | 0

답변 있음
how to write a function for the inbuilt function perms without using perms nor any built-in MATLAB permutation functions; nor any built-in string manipulation functions in the solution?
This is pretty clearly homework, so I doubt if anyone is going to state anything other than a hint. My own hint would be to wri...

대략 10년 전 | 0

답변 있음
Approximation of a differential system in a specific point
This requires the use of one of Matlab’s ode functions such as ode45. See http://www.mathworks.com/help/matlab/ref/ode45....

대략 10년 전 | 0

| 수락됨

답변 있음
Why isn't my integration using Trapezoidal Rule working?
The problem lies in the line x = pi/4:2:pi/3; It has only one point and 'trapz' is not happy with that. Try something ...

대략 10년 전 | 1

| 수락됨

답변 있음
I'm trying to write a function that calculates the max min and mean based on how many output arguments are used to call the function and I'm not sure why this doesn't work
Your function doesn't yield its results. You need this: function [x,y,z] = calcvals(varargin) or something equivalent ...

대략 10년 전 | 0

답변 있음
Matlab code for computing curvature equation
Your formula for curvature is that of a curve defined in terms of a parameter t in which x’, y’, x”, and y” all refer to derivat...

대략 10년 전 | 1

| 수락됨

답변 있음
How to set a condition for sequential number of non NaN values in a vector?
Let M be your matrix. [m,n] = size(M); T = diff([true(1,n);isnan(M);true(1,n)],1,1); T2 = false(1,n); for k = ...

대략 10년 전 | 1

| 수락됨

답변 있음
Generate new matrix from old matrix with specific conditions
[m,n] = size(R); f = 20; % <-- Check that f is a divisor of m A = reshape(cumsum(reshape(R,f,m/f,n),2),m,n);

대략 10년 전 | 0

| 수락됨

답변 있음
Problem with equating for loop index to a variable.
You should read Cleve Moler's document on the subject at http://www.mathworks.com/company/newsletters/news_notes/pdf/Fall9...

대략 10년 전 | 1

| 수락됨

답변 있음
Convergence program stuck at a point.
I think you are confusing things with your names of ‘old’ and ‘older’. What you need are the concepts of “too high” and “too lo...

대략 10년 전 | 0

| 수락됨

답변 있음
how to find all possible paths in MxM matrix
@Mohammad: Here is code that does not require any rejections - every row of matrix A represents a valid “path”. It differs from...

대략 10년 전 | 0

답변 있음
Create an array based on another array's input
Use the ‘histc’ function, [~,ix] = histc(x,grade_ranges), then use ix to index into a vector [‘A’,’B’,’C’,’D’.’F’].

대략 10년 전 | 0

답변 있음
how to find visual angle
The true angle between ba and bc would be: ang = atan2( abs((xa-xb)*(yc-yb)-(ya-yb)*(xc-xb)) , ... (xa...

대략 10년 전 | 0

답변 있음
Fixed Point Iteration - initial guesses
I think what you need, instead of the simple for-loop you have described which just executes a fixed number of times, is a while...

대략 10년 전 | 0

답변 있음
How can i know through MATLAB tool that given function is convex or not?
If your function has a second derivative, it is convex if and only if that second derivative is always non-negative. If the sec...

대략 10년 전 | 0

답변 있음
How do I test if a matrix is unitary?
Again, e^(i*H) is not the same as exp(i*H). Check matlab's "mpower" operator.

대략 10년 전 | 1

| 수락됨

답변 있음
How do I show that my matrix is unitary?
The problem lies in your interpretation of the expression e^(i*H). It is NOT the same as exp(i*H). What is called for here is ...

대략 10년 전 | 1

답변 있음
find nearest value on matrix
result = min(b(b>=1250)); For this to work, there has to be at least one element of b that is greater than or equal to 125...

대략 10년 전 | 1

답변 있음
Can finite difference method can be expressed with diff function?
Assuming A is n x n, B = diff(A,2,1)+diff(A,2,2); The array B would be of n-2 x n-2 size. The second argument of 2 in e...

대략 10년 전 | 0

답변 있음
Error in writing an equation (sin function)
The line Z=sin(X)*sin(Y)/(X*Y).; is the trouble. You need dots there: Z=sin(X).*sin(Y)./(X.*Y); so as to prod...

대략 10년 전 | 0

| 수락됨

답변 있음
how to get 1 to 500 odd numbers sum in matlab?
sum is (1+499)*250/2 Note: Legend has it that ten-year-old Carl Friedrich Gauss was given a similar problem by his instruc...

대략 10년 전 | 2

답변 있음
Create a new matrix with 0,-1 and 1 if and where in another matrix appears a max value
B = bsxfun(@eq,A,max(A,[],2))-bsxfun(@eq,A,min(A,[],2)); Note: I am taking you literally in regard to the equalities you r...

대략 10년 전 | 0

답변 있음
Creating a plane normal to an ellipsoid
Matlab’s ‘ellipsoid’ function, [x,y,z] = ellipsoid(xc,yc,zc,xr,yr,zr) creates an ellipsoid whose equation is: f(x...

대략 10년 전 | 1

| 수락됨

답변 있음
How to compute Permutation without repetition?
If a, b, c, etc. are different numbers, do this: v = [a,b,c,d,e,f]; P = perms(v); P = P(:,1:5); The matrix P wi...

대략 10년 전 | 1

| 수락됨

답변 있음
Removing duplicate rows (not "unique")
Let A be your matrix. [B,ix] = sortrows(A); f = find(diff([false;all(diff(B,1,1)==0,2);false])~=0); s = ones(lengt...

대략 10년 전 | 1

| 수락됨

답변 있음
Permutations of string without repetitions
As Stephen has warned you, twenty-five characters is a dangerous number to apply this problem to. Let’s talk about some more se...

대략 10년 전 | 4

더 보기