Answered
How to generate matrix using MATLAB ?
Here's another way: m = 4; n = 24; x = reshape(diff(floor((m*n+m*(0:m*n^2))/(m*n+1))),n,m*n);

12 years ago | 0

Answered
how to write the code for the following condition
If I understand you correctly, you have only one equation to satisfy and two variables that can be adjusted. If so, that means ...

12 years ago | 0

Answered
How can i get all the possible combinations of elements of a matrix?i dont want elements of the same column.i want to create vectors whose sum is smaller than a number
Nikos, there is a better way of determining the number of rows in G. It is not a formula but involves an iteration that is much...

12 years ago | 0

Answered
Why I am getting Error?
My guess would be that your JPEG files are not in a format that 'imread' expects. Try specifying their format.

12 years ago | 0

Answered
How can i get all the possible combinations of elements of a matrix?i dont want elements of the same column.i want to create vectors whose sum is smaller than a number
I had put your problem aside, Nikos, and only got around to working it out today. I have taken one liberty with your request. ...

12 years ago | 0

Answered
having trouble with for loops
Here's a way to check your answer: n = 1000; s = n*(n+1)*(2*n+1)/6; This gives you the same value as s = sum((1:n)....

12 years ago | 0

Answered
fsolve vs. lsqnonlin: Three intersecting spheres
This is not a direct answer to your question, Mosch, but I hate to see you use the iterative methods of 'fsolve' or 'lsqnonlin' ...

12 years ago | 1

| accepted

Answered
if else doesn't go through the loop
You have forgotten to index your zz entries in the for-loop. It should read: for Z = 1:numel(zz) if zz(Z)==1; % ...

12 years ago | 1

| accepted

Answered
How do I find a solution to (x.^2)/2-10*atan(x) using the Newton-Raphson method?
See the Wikipedia article at http://en.wikipedia.org/wiki/Newton's_method If you plot a graph of your function f(x) = x^2...

12 years ago | 0

Answered
Norm of a vector
For the "L2" norm of a vector v you can use sqrt(sum(v.^2)) This is only one form of the 'norm' function. See the docum...

12 years ago | 2

Answered
absolute value of a vector
That isn't true of matlab's 'abs' function. For every value in x it will return its absolute value. For every individual compl...

12 years ago | 1

| accepted

Answered
FINDING EQUILIBRIUM POINTS FOR NONLINEAR SYSTEM
I assume equilibrium occurs when dx1 and dx2 are equal to zero. You don't need matlab here. This one is easy to solve by hand....

12 years ago | 0

| accepted

Answered
Please help me to solve this problem!
By the way you have defined U, V, and W, they must have a curl of identically zero. There can be no vorticity. That is because...

12 years ago | 0

Answered
Error with remainder (rem) and fix - change problem
I suspect your difficulty is due, not to the 'rem' function, but to the impossibility of representing the fractional values 0.10...

12 years ago | 0

| accepted

Answered
Determine the maximum force, of your 1000 random forces, for which the cylinder will not fail. Determine the minimum force, of your 1000 random forces, for which the cylinder will fail. Output both values to the workspace.
I assume you are in the process of learning how to code in matlab or perhaps in any computer language. If so, it is useful to t...

12 years ago | 1

| accepted

Answered
Simulation for a triangle
The theory of the Monte Carlo simulation which you describe is, I presume, that if you enclose a triangle completely in a square...

12 years ago | 0

| accepted

Answered
how did they vary the angular velocity in this model ?
A fundamental law of mechanics is that a body free of external torques will preserve its angular momentum. However, that is not...

12 years ago | 0

| accepted

Answered
create a matrix based on a row distribution
A_new = B(distr,:);

12 years ago | 0

| accepted

Answered
Calculate recursive inhomogenous equation in Matlab
The codes for the two iterative procedures you asked about are: % The first one n = 16; % <-- Choose the value of n you ...

12 years ago | 0

Answered
Cannot get factorial loop to work! Do not know command...
Yet another way is: n = 100; y = n*(n+1)*(2*n+1)/6;

12 years ago | 2

Answered
How can I do bivariate numerical integration in Matlab for computing joint probabilities?
These can all be expressed in terms of the 'mvncdf' function. For (1) it would be: P1 = mvncdf(-b,mu,sigma); For (4) it ...

12 years ago | 0

| accepted

Answered
IF argument question I am seriously new to coding.
The trouble with your code is that 'c' as you have defined it, is a vector with many elements. When you write "if c<=0", the qu...

12 years ago | 0

Answered
Using Trapz for Integral Evaluation
This integral is divergent, since theta crosses over 1/2*pi and 3/2*pi where the cos(theta) becomes zero. Having the cube of r ...

12 years ago | 1

Answered
Calculate recursive inhomogenous equation in Matlab
This computes the value of x(n): x0 = 1; xn = 2; for k = 2:n t = xn; xn = 5*xn-6*x0+4*k-7; x0 = t; end The...

12 years ago | 0

Answered
Graph for the imaginary part of complex logarithmic exponential function
For any combination of elements of t and r your w can be expressed as w(r,t) = r^12*exp(12*t*i) so its logarithm is ...

12 years ago | 0

Answered
Question regarding Stochastic Value Function Iteration
The problem would appear to be the variable 'j' which you have in the line c = amat(j,1)*k0^alpha - k + (1-delta)*k0; % cons...

12 years ago | 0

Answered
Solving and plotting spring constant vs Force
There is no need to use the symbolic function 'solve' at each of 701 steps. If properly used, 'solve' could give you a general ...

12 years ago | 0

Answered
Out of memory error in combination combnk
The total number of rows you would get from combnk(1:121,10) is 121!/10!/111! which is 1.2652e14 which is a very large number in...

12 years ago | 1

| accepted

Answered
Precision when rotating vectors
I have not actually tried out your code, but based on my reading of it, it appears to have a serious flaw. For the sake of disc...

12 years ago | 2

Answered
Angles between 3 vector in 3d
The 'atan2' function is more accurate than 'acos' for vectors that are nearly parallel. For two 3D vectors v1 and v2, do this: ...

12 years ago | 0

Load more