Answered
Write a row and column vector as matrix index
a = [4 5 3]; % Generate index vectors A and B [A,B] = ndgrid(a,a); A = A(:) B = B(:) % Use A and B as index vectors for a m...

3 years ago | 1

| accepted

Answered
3D Contour plot. Filled slices/surfaces are black
The mesh lines are black and cover the colors. To remove them, use gr = slice(Xg, Yg, Zg, Vg,[],[],zslice); set(gr,'Edgecolor...

3 years ago | 0

Answered
Hoe can I convert my script to a function?
If the coefficients don't change in the course of the simulation, you should read "Coefficient.mat" only once and pass the matri...

3 years ago | 0

| accepted

Answered
a = b<0
"a" is a logical variable. It is set to "true" (=1) if b<0, else it is set to "false" (=0). The next operation c = 3*a works a...

3 years ago | 2

Answered
How to compare previous results in iteration?
You should never check whether two variables are equal. Always check whether they are approximately equal: difference = 1.0; o...

3 years ago | 1

Answered
Euler method: ODE with different initial conditions
Y0 = 0.5:0.05:1.5; hold on for i = 1:numel(Y0) y0 = Y0(i); [x,y] = euler(y0); plot(x,y) end hold off functio...

3 years ago | 0

| accepted

Answered
The solve function doesn't work properly
syms l1 l2 l3 H B phi gamma theta eq1 = l3*cos(gamma) - l2*cos(phi) + l1*sin(theta) + B == 0; eq2 = l3*sin(gamma) - l2*sin(ph...

3 years ago | 0

Answered
How can I avoid looping here?
STD_w=0.05; STD_gama=5; mean_w=linspace(15,40,10); sigma_w=ones(1,length(mean_w))*STD_w; mean_gama=linspace(115,85,10); sig...

3 years ago | 0

| accepted

Answered
Partial Least Squares regression - confidence interval of the predicted variable (response)
I did not look into your code in detail, but I think you could use the output structure "gof" from MATLAB's "fit" together with ...

3 years ago | 0

| accepted

Answered
recall Equation of fit curve and integrate
https://de.mathworks.com/help/curvefit/cfit.integrate.html

3 years ago | 0

Answered
Convert graph figure to equation
x = @(t) (t+4).*(t>-4 & t<-2) + (t-4).*(t>2 & t<4); t = -6:0.01:6; plot(t,x(t)) grid on

3 years ago | 0

| accepted

Answered
How to compare previous iteration output with current iteration output?
xold = 2; error = 1; while error > 1e-6 x = xold - (xold^2-2)/(2*xold); error = abs(x-xold); xold = x; end x ...

3 years ago | 0

Answered
The real() command outputs a complex number (doesn't appear to change it).
isreal(real(double(eigen(t)))) instead of isreal(real(eigen(t)))

3 years ago | 0

| accepted

Answered
introducing a comparison related to variables in linear programming
Your constraint says that X9 = max(0,X1+X2-Pdemand) X10 = max(0,Pdemand-(X1+X2)) Usually, it suffices to set the constraints ...

3 years ago | 0

Answered
How to use one fmincon optimizer in a loop and one optimizer out of that loop?
Why don't you optimize all parameters in one call to fmincon ? It's not a problem that Ea and k are different for each dataset,...

3 years ago | 1

| accepted

Answered
Why receive error Integrand output size does not match the input size?
x and y that are inputs to Hf from integral2 are usually matrices (of the same size). The output of Hf is expected to be of the...

3 years ago | 0

| accepted

Answered
Iteration of multiple nonlinear functions
%Given values k = 0.84; Qh = 25; Ti = -3; To = -3; hi = 6; ho = 20; dx = 0.002; dy = 0.01; n_steps = 1000; tau = 0.078...

3 years ago | 1

Answered
Pass variables between functions
If you type PB(Bmatrix,D) then Bmatrix and D are inputs to the function PB. Thus they must somehow be defined before this call...

3 years ago | 0

Answered
Error in using lsqcurvefit with constrained parameters.
Maybe fixedset = logical([0 1 1]); fixedvals = [3 4]; xvary = 33; x = zeros(size(fixedset)); x(fixedset) = fixedvals; x(~f...

3 years ago | 0

| accepted

Answered
numerical integration and solving for limit
Here is the maximum value you can insert for t: syms x f = 1/sqrt((1-x^2)+0.01/2*(1-x^4)); vpaintegral(f,x,-1,1) And here is...

3 years ago | 0

| accepted

Answered
errors on function vs time plot
t = linspace(-1,1,100); v = 12*exp(-8*t).*(t>=0); plot(t,v)

3 years ago | 0

Answered
Why doesn't my plot "go to infitnity"?
What finite y value do you want -inf to be in the plot ? Since nobody knows, MATLAB just skips these data points (same for NaN...

3 years ago | 1

Answered
How can I resolve this issue here, can anyone please help.
k1 is a vector. Thus with the commands dAdt(i) = dAdt(i) + k1.*yita_mn(i,j).*(At(j))*cos(Ot(j)-Ot(i)); dOdt(i) = dOdt(i) + k1....

3 years ago | 0

Answered
Double-check for any mistakes
- rho + gamma*(abar(t-1,1) - a(t-1,1)) - gamma*(a(t-1,1) - c(t-1,1)) - delta - (delta*a(t-1,1) + abar(t-1,1)*g_abar - gamma*(aba...

3 years ago | 0

| accepted

Answered
2nd order lineair non-homogenous differential equation with EULER not working properly
The number of steps to take to reach tend is (tend-tstart)/dT, not tend/dT. Further, you apply the initial conditions at t = -3...

3 years ago | 1

Answered
Solution of the equation
This code doesn't work since there does not seem to be a solution for some or all of the d values you supplied. I suggest you f...

3 years ago | 0

Answered
ans = Empty sym: 0-by-1 error in solving equation
syms x y Y = 0:1:100; avd=5; s = 0.25; paco2=40; r= 0.8; hb=14; pb=740; eqn = ((hb*(((((pb-47)*y-paco2/r).^3+150*((pb-47...

3 years ago | 0

Answered
Numerical integration of second moment of area for given data
x and y data describe the curves of the upper and lower profile ? https://math.stackexchange.com/questions/3126310/calculating-...

3 years ago | 0

Answered
Delete 0's in a matrix
% First case (see above) A = [0,0;0,0;800,1096;0,1461;1462,1701]; A( any(~A,2), : ) = []; A % Second case (see above) A = [...

3 years ago | 1

| accepted

Answered
Methods used inside "roots" and "solve" functions to solve polynomial equations.
For numerial computation of polynomial roots, see https://math.mit.edu/~edelman/publications/polynomial_roots.pdf https://de.m...

3 years ago | 0

Load more