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

さらに読み込む