Answered
Solving 2 parameters equation
I see no unknown variable ‘D’ here. Also the variable ‘Lc’ is not defined. Do you mean that Lc and nR are actually the two unk...

10 years ago | 0

Answered
Finding maximum value of y at some x
[~,p] = sort(y,’descend’); x2 = x(p(1:2)); % <-- x values at first and second maxima of y

10 years ago | 1

Answered
Why .^2 does not work as expected?
I think you need to convert I to ‘double’ before doing the exponentiation on it. As it is, I believe it is ‘uint8’ type and any...

10 years ago | 1

| accepted

Answered
Can I vectorize this any further?
My understanding is that - I admit I haven’t tried this - if you use the ‘bsxfun’ with its ‘fun’ defined as ‘besselj’ and the tw...

10 years ago | 0

| accepted

Answered
way to avoid for loops
This is for your revised problem involving the 'exp' function. (Note: I am assuming the x and y in your code are just as you ha...

10 years ago | 0

Answered
Generalizing algorithm to find all combinations of sums of vectors.
Let’s suppose that the g’s are the rows in an m by n matrix, G. That is, each n-element row is one of the g’s and there are m o...

10 years ago | 0

| accepted

Answered
How to set zeros to NaN in specific columns
T = reshape(A(:,2:6),[],1); T(T==0) = nan; A = [A(:,1),reshape(T,[],5)];

10 years ago | 1

| accepted

Answered
Why does my answer converges? "iterations"
You are apparently trying to solve a quadratic equation in z_v and a cubic equation in z_l. Instead of using the highly questio...

10 years ago | 0

Answered
way to avoid for loops
If x and y are arbitrarily defined as N-by-N arrays, do this: [I,J] = ndgrid(1:N); s = sum(x(:))*I+sum(y(:))*J; Wit...

10 years ago | 2

Answered
nonlinear differential equation system
Your three equations can be reduced to one equation. By using the second two equations it can be deduced that x2 = 2 - x1...

10 years ago | 1

| accepted

Answered
Inner matrix dimensions must agree.
As it stands, your ‘Z’ variable is empty. You write: “Z=10*10^-2:60*10^-6;”, and the colon operator by default counts up by one...

10 years ago | 0

| accepted

Answered
Nonlinear 3 equations 3 unknowns , hyperbolic, fsolve stopped because the last step was ineffective
It is relatively easy to convert your three equations in three unknowns into a single equation in a single unknown. That would ...

10 years ago | 1

| accepted

Answered
[x,y,z] = sphere, except uniform or random distributed points
Here is a way to generate random points on a sphere that is statistically uniform. r = randn(3,n); % Use a large n r =...

10 years ago | 4

| accepted

Answered
Is there any one who can help me how to sum the following summation expression? I tried but it said to many inputs. Thank you for your help!
The first result with ‘symsum’ very likely indicates that ‘symsum’ is unable to compute this particular infinite sum. The sec...

10 years ago | 0

| accepted

Answered
how can i determine why my code is accepting a non integer when it's not suppose to
Your instructions specified that if the input is invalid, you were to return an empty string. This you did not do. Instead your ...

10 years ago | 1

Answered
How can i make a code to find y of y''=y*y' ?
To solve your equation numerically using one of the ode functions, you set it up as two simultaneous differential equations: ...

10 years ago | 0

| accepted

Answered
need help solving this summation
Make these changes in your code: L=3; W=5; x=linspace(0,L,10); y = linspace(0,W,7); N=9; P = 1:2:N ...

10 years ago | 1

| accepted

Answered
Perimeter of a part of an ellipse
If (x0,y0) is the center of the ellipse, if a and b are the two semi-axis lengths, and if p is the counterclockwise angle of the...

10 years ago | 2

Answered
Using logical operator in an if condition
You are using the "short circuit" logical operators. They work for scalars but not for vectors with more than one element. In ...

10 years ago | 0

Answered
sub2ind gives an error: Error using sub2ind (line 43) Out of range subscript. How to solve this?
Part of your circle has indices of zero value which means the circle extends beyond the limits of K. Move it a little further t...

10 years ago | 1

| accepted

Answered
FLOPS in Complex Array Multiplication
I count six floating point operations per complex multiplication. If your matrix is N-by-N, that would be a total of 6*N^2 flop...

10 years ago | 1

| accepted

Answered
What is the problem with this for loop?
For each of the for-loops ‘clock’ can take only one value. For example, with "for clock = 1.000:1.999", clock can only be 1.000...

10 years ago | 0

Answered
why this command: a([],[],:)=A doesn't work? I try not to use for command
As you have defined ax and ay, they are: ax = 1:512; and ay = ones(1,512); Just look at them to see that. This ...

10 years ago | 0

Answered
How can I convert a 3D matrix to 2D matrix in the way specified in this post
result = reshape(permute(val,[1,3,2]),[],size(val,2)); % <-- Corrected

10 years ago | 2

| accepted

Answered
Random numbers drawn from power law with certain mean
You are correct that the distribution can by generated by b*rand(n,1).^(-D) where b and D are positive parameters. Th...

10 years ago | 1

| accepted

Answered
How I can extract data from a vector based on index
B = A(setdiff((1:length(A)).’,index(:))); or if you're sure A and index are row vectors just B = A(setdiff(1:length(...

10 years ago | 1

| accepted

Answered
Engineering Statics Problem in 3 dimensions
Yes, if you wish, you can solve your problem using matlab as follows: c1 = cross([0;0;2],[.2673;.8018;.5345]); c2 = cr...

10 years ago | 0

Answered
How to use the Golden-Section Search for finding the MAX f(x) value?
Finding the maximum would work the same way as with the minimum except that 1) you need to work in an interval for which your fu...

10 years ago | 0

Answered
Integral of controllability gramian
In matlab there is a very important difference between e.^((A.’)*τ) and e^((A.’)*τ) (without the dot.) The first of these is an ...

10 years ago | 0

Answered
I need to extract a row that coincides with a number in the first column.
I agree with Cyclist’s comment as to the lack of clarity in your request, but I will take a very wild guess as to what you are a...

10 years ago | 0

Load more