Réponse apportée
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...

presque 10 ans il y a | 0

Réponse apportée
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...

presque 10 ans il y a | 0

Réponse apportée
Help please - How to extract row and column from matrix from certain value
[row,col] = find(M==1048); where M is your matrix.

presque 10 ans il y a | 0

Réponse apportée
Add a number of zeros to matrix row depending on its content.
V = zeros(max(A),1); V(A) = 1; B = diag(V);

presque 10 ans il y a | 0

Réponse apportée
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...

presque 10 ans il y a | 0

Réponse apportée
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....

presque 10 ans il y a | 0

| A accepté

Réponse apportée
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 ...

presque 10 ans il y a | 1

| A accepté

Réponse apportée
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 ...

presque 10 ans il y a | 0

Réponse apportée
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...

presque 10 ans il y a | 1

| A accepté

Réponse apportée
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 = ...

presque 10 ans il y a | 1

| A accepté

Réponse apportée
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);

presque 10 ans il y a | 0

| A accepté

Réponse apportée
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...

presque 10 ans il y a | 1

| A accepté

Réponse apportée
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...

presque 10 ans il y a | 0

| A accepté

Réponse apportée
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...

presque 10 ans il y a | 0

Réponse apportée
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’].

presque 10 ans il y a | 0

Réponse apportée
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...

presque 10 ans il y a | 0

Réponse apportée
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...

presque 10 ans il y a | 0

Réponse apportée
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...

presque 10 ans il y a | 0

Réponse apportée
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.

presque 10 ans il y a | 1

| A accepté

Réponse apportée
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 ...

presque 10 ans il y a | 1

Réponse apportée
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...

presque 10 ans il y a | 1

Réponse apportée
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...

presque 10 ans il y a | 0

Réponse apportée
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...

presque 10 ans il y a | 0

| A accepté

Réponse apportée
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...

presque 10 ans il y a | 2

Réponse apportée
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...

presque 10 ans il y a | 0

Réponse apportée
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...

presque 10 ans il y a | 1

| A accepté

Réponse apportée
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...

presque 10 ans il y a | 1

| A accepté

Réponse apportée
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...

presque 10 ans il y a | 1

| A accepté

Réponse apportée
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...

presque 10 ans il y a | 4

Charger plus