Answered
how to make an indicator function in loop
You could do the following in Matlab: for i = 1:length(x) Y = y(i); ll(i) = log(p0)*(Y==1) + log(p1)*(Y==2) + log(p2...

5 years ago | 0

| accepted

Answered
How do I fix the 'Invalid use of operator' Error in my anonymous function bisect code?
Your syntax isn't correct. Try f = @(x)x^7+3*x-1; xl = 0; xu = 1; es = 10^-4; maxit = 30; [root,fx,ea,iter]=bisect(f ,xl,x...

5 years ago | 1

| accepted

Answered
How to find unknown variable in the below equation?
The equation is a cubic in Unu^2, so the following uses roots to find solutions: r = 3.88; Vau = 43; theta_u = 71.8; gamma =...

5 years ago | 1

| accepted

Answered
How to plot this equation and get this curve??
The following plots the curves: Cfn = @(CdB) 10.^(-CdB/20); Tfn = @(C,M) (1 - C./M.^0.5)./(1 - C.^2).^0.5; Afn = @(T) -20*log...

5 years ago | 1

Answered
Calculate Lyapunov spectrum for Lorenz system
It seems to be the w = orth(J*w); command that creates the problem! if you replace it with w = J*w; you get more reasonable...

5 years ago | 1

Answered
Matrix division "in scalar way"
X = Y ./ (Z .* 2); Note the dot by the divide sign.

5 years ago | 0

| accepted

Answered
How to replace vector value '0' to NaN( 0 -> Nan)
>> Distance = [0 1 2 3 0 4 0 5 0 6 7 8 0 9 10] Distance = 0 1 2 3 0 4 0 5 0 6 ...

5 years ago | 0

Answered
hi I have a code to plot the results of a for- loop I would though like this to start at my first value of x
Change your loop slightly: for ii = 1 : N anArray(ii) = x; %%%%%%%%%%%%%% x = x - f(x)/d(x); position = ii + 1...

5 years ago | 0

Answered
Help with Elastic Collision
You need to be careful about pre and post collision velocities, and the boundary checks: t=0; dt=0.5; x1=1; y1=0; v1x=0; v...

5 years ago | 0

| accepted

Answered
matlab ode15i solver
I don't know if this is the issue, but in your first and thrid equations, as well as having x_p(t) you also have x_p (without th...

5 years ago | 1

Answered
Unable to perform assignment because the left and right sides have a different number of elements.
You have a y instead of y(i) in one place. Try: y(i+1) = y(i) - .00005*((1 + y(i)).*(27.92*10^(-11)*(t(i).^3+3*t(i).^3.*y(i)))...

5 years ago | 0

| accepted

Answered
Linear equation minimization problem
Like so: >> A=[1 1 1 1 1 0 1 0 0 0 1 1 0 0 1] >> V = [4 6 7] A = 1 1 1 1 ...

5 years ago | 0

Answered
Solving a non-linear ODE with coupled algebraic equations
Yes, that's exactly what I've done in the program below. However, in order to get anything like the results in the paper (which...

5 years ago | 0

| accepted

Answered
I want my loop to run backward and print all values which are before 5.
Try d(j) = j; instead of d = j; to store all values of j.

5 years ago | 1

Answered
why do i get this nan
UL is generating numbers too large for E3. Try reducing UL to 90.

5 years ago | 1

Answered
How to insert calculation values in to a zero matrix
Z = Dr(:,3) should do it.

5 years ago | 0

Answered
How to create randomly placed points within a 3D rectangle?
Do you mean something like this: % length, width and height of box L = 3; W = 2; H = 1; % pick plenty of random points x = L...

5 years ago | 0

| accepted

Answered
How to create matrix and solve for answers?
% Your equations are: % A + S + C = 500; % 18*A + 15*S + 12*C = 8070; % A = 3*C; % where A = nbr of adults, B = nbr students...

5 years ago | 1

| accepted

Answered
Finding a matrix representing points of sphere
Why can't you use sphere? You can get your matrix as follows: N = 19; A = (N+1)^2; R = 2; % Example data with R as sphere rad...

5 years ago | 0

Answered
Solving using an ode
Here's a "quick and dirty" way to do it, using interpolation to find the time. s = [0.60, 0.64, 0.68, 0.72, 0.76, 0.80]; x0 = ...

5 years ago | 0

Answered
creating a matrix from vectors
Here's one way: Ta_new = Ta; for i = 1:30 Ta_new = [Ta_new Ta+i*k]; end

5 years ago | 0

| accepted

Answered
i need a program for the problem that i have posted below
The m refers to metres! It shouldn't be included in your expression for x. Remove it and you should get your desired plot.

5 years ago | 0

| accepted

Answered
Plotting two variables, getting graph and x intercept
Here's an alternative f = @(x,y) x.^3 + 6*x.^2 + 4*(1-y.^2); coeff = @(y) [1 6 0 4*(1-y.^2)]; y = 0:4; for i = 1:length(y) ...

5 years ago | 0

Answered
Convergence of a variable in matlab
If you set Beta to be 15 and keep kc at 0.3, BUT change the signs of your ode's so that the function looks like function dz = r...

5 years ago | 0

Answered
Convergence of a variable in matlab
Here's a Matlab ode version in which I've used Beta = 20 (obviously you can change that). Are you sure you've got the signs on ...

5 years ago | 1

| accepted

Answered
Why is it so hard for MATLAB to solve the following symbolic equation
This seems to work syms rp alpha beta theta psi z A=cos(alpha)-cos(beta); B=sin(alpha)-sin(beta); C=(cos(beta)-1)/tan(beta)-...

5 years ago | 0

| accepted

Answered
Replacing the minimum of a vector
In your first one the minium value of x is 3, so Matlab replaced the third element with inf. Similar comments apply to the othe...

5 years ago | 0

Answered
What is the meaning of p(1, :) in the following lines?
It refers to the first row and all columns of matrix p. So find(p(1,:) < -1.5+eps); means look through all the columns of the...

5 years ago | 0

| accepted

Answered
Solve nonlinear equation- problem with fzero results
You don't seem to have an "end" to go with your "for" loop. x(1) = 0 can go before the "for" loop. Insted of ... fun = @Eq_...

5 years ago | 0

Load more