Answered
Help finding the min and max of a matrix without using min/max commands
Change the two lines max=mat2; min=mat2; to max = -inf; min = inf; Note: It is a poor practice to use ...

10 years ago | 0

| accepted

Answered
Help with iteration!!?
Your while-loop does not seem to be very useful. On the first pass through it sets Wd equal to Wdf and because the "(Wdf-Wd)> 0...

10 years ago | 0

Answered
To reshape the number of elements must not change matlab error
It looks to me as though your original 'bits' array contains a number of elements other than n*m. You can't change the total nu...

10 years ago | 0

| accepted

Answered
check points inside triangle or on edge with example
Suppose P1 = [x1,y1], P2 = [x2,y2], and P3 = [x3,y3] are row vectors giving the coordinates of the three vertices of a triangle,...

10 years ago | 2

| accepted

Answered
Calculate Exponentials WITHOUT built-in exponent function?
Trying to compute x^n using only summation is a terrible method. Surely you would be allowed to use multiplication! ExpVa...

10 years ago | 1

| accepted

Answered
How to increase the speed of this code?
Try 'ndgrid': [X,Y,Z] = ndgrid(0.01:0.01:1); pts = [Z(:),Y(:),X(:)]; %(Corrected)

10 years ago | 0

| accepted

Answered
Keep getting error: Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding your available stack space can crash MATLAB and/or your computer.
Your code is clearly meant to be recursive. However, there is something wrong in the way it is planned. You first call "equili...

10 years ago | 0

Answered
Monte Carlo Experiment in Huffman
In case you don't have access to a huffman compression algorithm, I would expect in your particular case the huffman encoding wo...

10 years ago | 0

Answered
How to get the inverse function when it's only 1-1 in certain range?
As you have defined iphi2 it is simply one of the two solutions to a quadratic equation: z = 1-sqrt(1-phi2)

10 years ago | 0

Answered
I want to make this assignment : Const = log(2)/703 800 000 but i keep getting this error massage, 'Matrix dimensions must agree' and I have no idea what that even means. How do I go about this?
If "730 800 000" is meant to be a three-element row vector you need to write: const = log(2)./[730 800 000]; If "730 80...

10 years ago | 0

Answered
Error using ==> times Matrix dimensions must agree.
Your vector t is a row vector, that is, presumably 1 by 1024 in size. If there is no complaint in plot(t,x), then x must also b...

10 years ago | 0

| accepted

Answered
How to write function that recognizes whether a year (e.g2010) input by user is leap year or not
I recommend you put matlab's 'mod' function to good use. Here is one way: t = mod(y,4)==0 & (mod(y,100)~=0 | mod(y,400)==...

10 years ago | 0

Answered
How to get rid of the error: Error using horzcat. Dimensions of matrices being concatenated are not consistent.
Both the expressions for A and B are invalid. In A the three quantities zeros(3,3), eye(3,3), zeros(3,1) have a total ...

10 years ago | 0

| accepted

Answered
Solving the following integral in MatLab
If b and c are both nonzero, then as x approaches infinity the factor exp(-c*x/(a-b*x)) approaches exp(c/b) which would be nonze...

10 years ago | 0

| accepted

Answered
finding four solution in an interval
Use matlab function 'fzero' to find solution to fun = @(x) exp(-2*x).*sin(x+4)-0.4; x = fzero(fun,x0); where x0 is ...

10 years ago | 0

Answered
Help-Integration of Bessel functions
It is likely that an explicit expression for either of those integrals as functions of 'a' is not known in mathematics and there...

10 years ago | 0

| accepted

Answered
Help-Integration of Bessel functions
Use numerical integration with matlab's 'integral' function or one of the other quadrature functions.

10 years ago | 0

Answered
Trying to use quad to solve this integral but keep getting error
You've forgotten the dot in your division. It should be: y = @(x)((1.941-24.3*x).^2)./(2.92*(0.02408-x)*(0.01605-x));

10 years ago | 0

Answered
fill matrix randomly with a specific number of units
The tough part of your requirement is to not duplicate rows. The following while-loop is intended to accomplish that. v =...

10 years ago | 0

| accepted

Answered
How to generate a random integer betwwen a and b inclusive.
x = 9*rand(n,1)+1; As to "inclusive" this will never give exactly 1 or exactly 10. However if you intended to have an uni...

10 years ago | 0

Answered
comparing numbers on the same vector
y(1) = true; for k = 2:length(x) y(k) = (max(x(1:k-1))<x(k)); end y = double(y);

10 years ago | 0

| accepted

Answered
To reflect a contour plot
If your symmetry is in the left-right direction, then do: contour(V(:,end:-1:1),500); However, that leaves the two imag...

10 years ago | 0

| accepted

Answered
Using ode45 to solve second order differential system
The same single function 'x' cannot in general satisfy two different differential equations, so you need to solve these equation...

10 years ago | 0

Answered
Finding angle between thee points
To find the angle rotating counterclockwise from point P1(x1,y1), pivoting around point P2(x2,y2), and ending at point P3(x3,y3)...

10 years ago | 0

Answered
how to calculate all permutations of ['a' 'b' 'c' ... 'x' 'y' 'z'] just 26 characters, yet combinator.m combinations.m return errors
@John: I think you fail to grasp the enormity of 26 factorial. Suppose one of us could come up with your requested scheme of pr...

10 years ago | 3

Answered
I am trying to obtain a series of vectors made of elements from a larger vector given they exceed a threshold
It's not clear whether you want those Z elements which exceed some fixed value or those which make up a monotone increasing sequ...

10 years ago | 0

Answered
How to plot a 3rd order best fit line through 3 sets of data?
How about x1 = [Cv80(:);Cv50(:);Cv30(:)]; y1 = [Cp80(:);Cp50(:);Cp30(:)]; p = polyfit(x1,y1,3); y = polyval(p,x1);...

10 years ago | 0

Answered
How to solve 5 quadratic equations simultaneously
For that particular set of equations you could take steps to make things easier. Introduce a new unknown 't': t = LIDtot-x...

10 years ago | 2

| accepted

Answered
When I plot, I only get 5 red dots and a blank graph.
You should make two changes: x = linspace(0, 1, w); (or just linspace(0,1) and get the default hundred points) VR = ...

10 years ago | 2

Load more