Answered
I do not know why this is not plotting the multivariable function correctly?
F = X.*(10*Y+3).*(exp(-X.^2-Y.^2)); instead of F = X*(10*Y+3)*(exp(-X.^2-Y.^2));

4 years ago | 0

| accepted

Answered
Error using vertcat Dimensions of arrays being concatenated are not consistent.
Works for me. Maybe your input to A and B is wrong. Try A=[1 2;3 4]; B=[1;2] e.g.

4 years ago | 0

Answered
Index exceeds the number of array elements
Q=(int(diff(p),theta)); should be p, shouldn't it ?

4 years ago | 0

Answered
Solving 3 equations with 3 unknowns using for loop ?
You can't get a solution that fulfills all three equations exactly. The reason is that ((Xb-Xm*25e-3)*(-230.6815e-6))/((1.05e...

4 years ago | 0

Answered
Why do I get "no solution found" in fsolve while there is the actual value for them?
You might want to try ff = @(H)f(H).^2 H0=ones(1,20); [H,Hval]=fsolve(ff,H0)

4 years ago | 0

Answered
Calculate volume encapsuled by two surfaces
fun = @(x,y) max(fun1(x,y)-fun2(x,y),0); vol = integral2(fun,-4,4,-4,4)

4 years ago | 0

| accepted

Answered
Store final values from simulations of differential equation
XS = zeros(numSims,2); for j = 1:numSims % numSims is the number of independent % Stochastic simulations I want ...

4 years ago | 1

| accepted

Answered
Why does lsqnonlin find wrong coefficients?
diff = (x(1) *X(:,1) + x(2) * X(:,2) + x(3) * X(:,3) + x(4) * X(:,4)) - y; instead of diff = (x(1) *X(1) + x(2) * X(2) + x(3) ...

4 years ago | 1

| accepted

Answered
How do I use Euler's forward difference method and the second order Runge-Kutta method to work out a third order ODE?
Don't work with y1, y2 and y3, but with y = (y(1),y(2),y(3)). Define the vector of derivatives as f = @(t,y) [y(2) y(3) 3*y(2...

4 years ago | 0

| accepted

Answered
Neural Network Loss Function: Mean (absolute) Cubic Error
You want the error to be negative if t_i < y_i ? This won't work: The loss function should always be non-negative.

4 years ago | 0

Answered
Solving differential equation with Runge Kutta 4th order
y0 = 0.3075; tspan = [0 6]; [t,y] = ode45(@trial_ODE45,tspan,y0); plot(t,y,'-') function dydt = trial_ODE45(t,y) parame...

4 years ago | 1

Answered
How to deal with the connection between symbolic caculations and numerical caculations?
"matlabFunction" converts symbolic expressions into function handles for numerical calculations. help matlabFunction

4 years ago | 1

| accepted

Answered
How to solve the equation to get the result in atan2 form?
syms phi theta psi ROT = [cos(theta)*cos(phi)+sin(psi)*sin(theta)*sin(phi), -cos(theta)*sin(phi)+sin(psi)*sin(theta)*cos(phi), ...

4 years ago | 0

Answered
Problem with ode45
cons = [con1,con2,con3]; tspan = [0 5]; [t,x] = ode45(@(t,x)odefcn(t,x(1),x(2),x(3)), tspan, cons); plot(t,x(:,1),'color','c'...

4 years ago | 1

| accepted

Answered
Can the equations in the differential equation group be represented by symbols when matlab ode solves the differential equation group ?
function dcdzh2h2sco2_centri = dcdzh2h2sco2_centri(z,c) R = 8.314; g = 1000; Mi_h2s = 34; Mi_co2 = 44; Mi_ch4 = 16; syms...

4 years ago | 1

| accepted

Answered
Trying to solve 2 dimensional Partial differential equation using Finite Difference Method
For dx = dy = 0.01, Nx = Ny = 101, not 30 in your code. I just realized this after setting up the code below. dx = 0.01; dy ...

4 years ago | 1

Answered
How do I create this full diagonal matrix
n = 10; A = zeros(n); for i=1:n-1 A = A + diag((n-i)*ones(n-i,1),i) + diag((n-i)*ones(n-i,1),-i) end A = A + n*eye(n...

4 years ago | 0

Answered
OR gives invalid results
if left == 1 || left == 3 ... The condition "3" is empty and thus true. MATLAB does not relate the "3" to "left".

4 years ago | 0

| accepted

Answered
matrix elements must be finite
I get the error message that chol cannot be used since the input matrix is not positive definite. Analyze Pxx - maybe it has Na...

4 years ago | 0

| accepted

Answered
Polynomial surface fitting problem with constraint y <=1
If N is the number of (y12,x1,x2) data, use fmincon instead of lsqcurvefit and set the constraints a*x1_i^b + c*x2_i^d - 1 <= 0...

4 years ago | 1

Answered
Simultaneously solve over-defined system of 35 equations, with only 2 unknowns
Put the coefficients in a (35x2) matrix A and the numbers of the right-hand side in a (35x1) vector b. Then you can solve for C...

4 years ago | 1

Answered
How to obtain a histogram for 3d data?
Since your curves are all 1d, a 1d- histogram suffices if you identify x-axis coordinate with curve length or parametrized point...

4 years ago | 0

Answered
Is it possible to do a search in a table for a value nearest to a number I want?
array = [1 3; 2 4; 5 4; 7 10; 9 3; 100 12; 44 22; 65 11; ...

4 years ago | 0

Answered
solve Nonlinear PDE and compare the analytical and numerical solutions
D = 3e-3; xstart = 0.0; xend = 1.0; dx = 1/400; tstart = 0.0; tend = 0.5; dt = 0.01; X = (xstart:dx:xend).'; T = ...

4 years ago | 0

Answered
Check for incorrect argument data type or missing argument in call to function 'matlabFunction'.
If i and p(1,i) and p(2,i) are defined, you should use p(1,i) = 3.0; p(2,i) = 15.0; g = @(val)(p(1,i)-val(1)).^2+(p(2,i)-val(...

4 years ago | 0

Answered
Minimum and Maximum value of fitted curve
p = polyfit(x,y,4); dp=polyder(p); ddp=polyder(dp); r=roots(dp); r=r(abs(imag(r) ) < 1e-6); maxima=r(polyval(ddp,r))<=1e-6 ...

4 years ago | 1

Answered
how to get common range for several intervals
Maybe not the most elegant solution, but it should work: Data=[26 27 22 23.3 22.5 23.4 22 23 20 23.7 2...

4 years ago | 0

| accepted

Answered
Unable to solve this coupled boundary value differential Equation
bvp4c is the appropriate tool to set up this problem. For this, rewrite your equations as dy(1) = y(2) dy(2) = y(3) dy(3) = ...

4 years ago | 0

Answered
I would like to ask how to perform nonlinear fitting with two fixed endpoints. Thank you very much for your answer.
If your fitting function depends on n parameters to be fitted, the condition that the function passes through 2 fixed points mak...

4 years ago | 0

| accepted

Answered
How to numerically solve and plot after solving the integration with a constant Multiplication
B = 51; C = 10; S0 = ...; lam_d = ...; H1 = (1/pi)*(S0./lam_d).^2; K= @(t) (sin(t)-t.*cos(t)).^(1/2).*(sin(t)+ 51*sin(10*t)...

4 years ago | 1

Load more