Answered
Syntax for optimization with integer and continuous variables, nonlinear equalities and inequalities?
Concerning your attempt with "ga": See the Note below from the documentation of "ga": x = ga(fun,nvars,A,b,Aeq,beq,lb,ub,nonl...

3 years ago | 1

Answered
issue with simple nested integration of several variables
The problem with integral/integral2/integral3 is always that they call your function not with scalar arguments for the independe...

3 years ago | 0

| accepted

Answered
How to use Cartesian coordinates to create Grid Surface?
If the CAD file describes the surface of the body in question, there should be a value for the elevation associated with each (x...

3 years ago | 0

Answered
Solving an integral within a partial derivative
You have to solve a second ordinary differential equation for y: dy/dt = 2*Ste * theta_f*(1-Ste/3 * theta_f + 7/45*Ste^2*theta_...

3 years ago | 0

Answered
How to use a user defined function inside the curve fitting function?
Use "lsqcurvefit". There are lots of examples under https://uk.mathworks.com/help/optim/ug/lsqcurvefit.html that show how to ...

3 years ago | 0

Answered
Why does the vectorized function give wrong result?
Compare Fun1 and Fun2. In Fun1, xo is computed using u while in Fun2, both xo and xe are computed using b. Further, the sorting ...

3 years ago | 0

| accepted

Answered
what happens behind "/"
If x = [2 3 4 5 6] and y = [3 4 5 6 7], then x/y determines the number "a" for which the error when approximating x by a*y is mi...

3 years ago | 2

| accepted

Answered
The function is debugging too long...
But the secant method is very different from your code - something like this: clc, clear all, close all x1=linspace(-pi/2,p...

3 years ago | 0

Answered
solving system of equations
I wonder what you expect as solution for 1 equation with 7 unset parameters. Say you have the equation g = x + c1 + c2 + c3 +...

3 years ago | 0

| accepted

Answered
Error using plot for Fourier series
I'm not sure what you try to do. Maybe something like this: clear all syms x L = 2; f = piecewise(x<=L/2,x,x>L/2,(L-x));...

3 years ago | 0

Answered
How to vectorize the following piece of code by removing the two for loops?
clear all;clc u=[3 4 30 50];% Desired Vector b=u; [R,C]=size(b); P=C/2; M=2*C; k = (1:M).'; i = (1:P); xo = sum(1*exp(1i...

3 years ago | 0

| accepted

Answered
how to express operators in symbolic algebra
Maybe like this syms x syms P(x) q(x) q(x) = x^2 P(x) = diff(q(x),1) + 5 ? You can't define P as a function of a dependen...

3 years ago | 0

Answered
what is different between the codes?
In both cases, you want to solve one equation in three symbolic variables (x,K,M). In your first code, MATLAB is able to determ...

3 years ago | 0

| accepted

Answered
How can I fix this problem?
You call "fsolve" with a vector of initial values of length 4, but within your function fonk1, you expect a vector x of length 5...

3 years ago | 0

Answered
how i could let the graph be at zero and then start at a specific point like this ? (yellow heighlight)
P1 = [-2;0]; P2 = [-0.5;0]; P3 = [0.5;0]; P4 = [2;0]; t = -0.5:0.001:0.5; ft = sin(t*22*pi); plot([P1(1),P2(1),t,P3(1),P4(...

3 years ago | 0

Answered
Standard deviation error bars for each interpolated value of temperature
You mean the graphics if you add the line errorbar(xq,average_vq_10,err_10,"blue") at the end of your code from above ?

3 years ago | 0

Answered
numerical solution for heat equation
I think your discretization should be done using the FV-method. Here, the volumes and areas of the bricks - expressed with dx, d...

3 years ago | 0

| accepted

Answered
Precision of intersecting a ray with a cylinder without symbolic expressions
w_c = 0.15; %width of the cylinder h_c = 0.15; %height of the cylinder P_0 = [0;0;h_c]; %starting point of the ray for i = ...

3 years ago | 0

| accepted

Answered
How can I illustrate the objective function and their constraints in function file?
I'm sure you can use a loop to define the constraints, and I'm sure you will find out how. C = 5; S = 3; N = 6; prob = optim...

3 years ago | 0

Answered
In an assignment A(:) = B, the number of elements in A and B must be the same. Error in Skeleton_Code_Problem_11 (line 152) y(n+1) = y(n) + dt*(-y(n) - ACE + (PE1 + PE2
Use %Calculating ACE ACE = B*(((w1(n)-ws) + (w2(n)-ws) + (w3(n)-ws))/3); instead of %Calculating ACE ...

3 years ago | 0

Answered
Need help to make a ode function asign a value
A,,B,C,D,E,rho and n are undefined. And you must supply V to your ode-function using [tn,xn] = ode45(@(t,x)tempo_SysEDO_NL(t,x...

3 years ago | 0

Answered
2D Interpolation/Extrapolation on Irregular shaped grid
In order to use "interp2", you must specify a rectangular region where values of your function are given on a regular grid. Thus...

3 years ago | 0

Answered
Is there anyway to increase the calculation speed of this sqrt integral2 without loosing accuracy?
The solution of the 2d-integral via an ode problem is adaptive and fast. It's somehow like applying iterated "trapz", but adapt...

3 years ago | 0

Answered
why does the following code give error?
Use xo(1,k)=xo(1,k)+1*exp(1i*((-pi/2)*sin(u(P+i))*(k-1)+(pi/(16*u(i)))*cos(u(P+i))^2*(k-1)^2)); xe(1,k)=xe(1,k)+1*exp(1i*((k...

3 years ago | 0

| accepted

Answered
Ode15s , Plotting issue.
Choose less output times from the solver, e.g. by setting tspan = linspace(tcut(i), tcut(i+1),(tcut(i+1)-tcut(i))/10) inst...

3 years ago | 0

Answered
CasADi Integrator setup for transport equation
With a velocity of 100 and a length of 4 for the region of integration, it takes at most 4/100 sec until "rho" gets constant and...

3 years ago | 1

| accepted

Answered
求救TT HELP WITH THE PDE error (too many input arguments)
If you transfer inputs to the pdepe functions by c = pdepe(0,@slowsorpde,@slowsorpic,@slowsorpbc,x,t,options,... D,v,theta...

3 years ago | 0

Answered
How to fit the parameters of a custom curve that includes integration and series summation
The solver will supply trial values for the unknown parameters. So you "only" need to write a function that - given hw and value...

3 years ago | 0

| accepted

Answered
How do I avoid the mistake?
x in your code is a scalar, not a vector. Thus something like x(k) does not exist. You could work with xold and x where xold wo...

3 years ago | 1

| accepted

Answered
Calculate a numerical value for the Conditional Tail Expectation (TVaR) at probability level 0.9 for the inverse Gamma distribution with parameters α = 3, and θ = 50, 000
syms x alpha = 3; beta = 50000; f = beta^alpha/gamma(alpha) * (1/x)^(alpha+1) * exp(-beta/x); F = igamma(alpha,beta/x)/gamm...

3 years ago | 0

Load more