Answered
How to multiply a 3d array with a 2d matrix?
Just the other way round: mtx_c = zeros(size(mtx_a,1),size(mtx_a,2),size(mtx_b,2)); for i = 1:size(mtx_a,1) M = squeeze(m...

4 years ago | 1

| accepted

Answered
Using ode45 to solve system of ODEs with some initial conditions and some terminal conditions
This is a boundary-value problem. Use BVP4C or BVP5C instead of ODE45.

4 years ago | 0

| accepted

Answered
Plot closed convex set in 2D
If f is only one function and not a vector of functions, use "fimplicit". fimplicit(@(x,y) x.^2+y.^2-1);

4 years ago | 1

Answered
Please find the mistake in this code.
alpha = -0.1; sigma = 0.1; eps = -0.1; e = 0.2; M = 10; a = 2; %figure psi_list = [10, 20, 30, 40, 50]; lambda = 0:0.2:4...

4 years ago | 0

| accepted

Answered
optimization and estimate parameters of ODE model to fit experimental data, with not enough experimental data
Check whether your temperature T in the Arrhenius terms really equals the integration time. I doubt it. A0=[1.3*(10^8),2*(10^8...

4 years ago | 0

| accepted

Answered
Solving equation with two variables, and giving the result for one as a function of the other
Alpha0 = 2.0; Ze_grad = 3.0; Alpha = fsolve(@(x)fun(x,Ze_grad),Alpha0) fun(Alpha,Ze_grad) function res = fun(Alpha,Ze_grad...

4 years ago | 0

| accepted

Answered
Integral in matlab func
You get this error because you didn't assign a value to the variable "time" when you called "meas" or a value >= 0.01. If you g...

4 years ago | 0

Answered
How can I speed up vpasolve when solving 2 equations, 2 variables?
ymin = 65; ymax = 75; ysteps = ymax - ymin + 1; %the FOC of the problem in the second period (derivative wrt s2) s0 = [1 5];...

4 years ago | 0

| accepted

Answered
How can I solve a second degree DAE ?
Write your equations as dx/dt = x2 dx2/dt = 1/m * (- f2(x-x1, x2 - dx1/dt)) 0 = f2(x-x1, x2 - dx1/dt) - f1(x1,dx1/dt) Are yo...

4 years ago | 0

| accepted

Answered
the integral of the Bessel function in Matlab
Seems there is no analytical solution for this integral (see MATLAB output above). Give values to the variables and use numeric...

4 years ago | 0

| accepted

Answered
Integrating this function and trying to solve for a variable displays errors!
L = 1;E = 1;I = 1;F=1; func = @(initial) L/sqrt((E*I)/(2*F)) - integral(@(theta)1./sqrt(cos(initial)-cos(theta)),initial,pi/2);...

4 years ago | 1

| accepted

Answered
My plot is empty...?
Change x = 15 : 1 : 50 ; to x = (15 : 1 : 50).' ;

4 years ago | 0

Answered
Setting up a problem in linprog
I think the whole procedure only makes sense if x1 is a subset of x2, but here we go: scale = 1.5; x1 = [0,4,6,10,15,20]*scal...

4 years ago | 1

| accepted

Answered
Summation of multivariable symbolic functions
Why do you want f to be a symbolic rather than a numerical function ? a = [3;5]; y = [-2;1]; x = [1;pi]; X = [3 4;-0.345 8];...

4 years ago | 1

| accepted

Answered
mpower doesn't work with symbolic matrix
A = sym('a%d%d', [2 2]); A^2

4 years ago | 0

Answered
create a sparse multidimensional matrix
i(1) = 3; j(1) = 1; v(1) = 1.0; i(2) = 7; j(2) = 2; v(2) = 1.0; i(3) = 11; j(3) = 3; v(3) = 1.0; m = 12; n = 3; A = s...

4 years ago | 0

Answered
Use lsqnonlin to optimize parameters to fit the property of a function
lsqnonlin slightly changes the input to "fun" from the first to the second call, but does not recognize any change of the output...

4 years ago | 0

Answered
lsqcurvefit requires all values returned by functions to be of data type double.
Setting y = e/f*sind(theta) makes no sense because this setup will have infinitely many solutions. Use a single parameter e ins...

4 years ago | 0

| accepted

Answered
Using Contourf to Create Contour Plot with XYZ Data
This will work, but I don't think the interpolation of the Z data fits your needs. x = [ 185 168 151 134 11...

4 years ago | 0

Answered
Inserting functions in a vector function
g = @(x) x.^2; f = @(x) x.^4; for i = 1:3 f = @(x) g(f(x)); v{i} = f; end x = 4; v{1}(x) v{2}(x) v{3}(x)

4 years ago | 0

| accepted

Answered
Relatively easy optimization problem in Excel it's hard to implement on Matlab
If you accept a MATLAB solution for this problem: min: norm(X*p-y) s.c. xt = data*w 0<=w<=1 w integer where p is (3x1) and...

4 years ago | 0

Answered
How to perform linear curve fitting based on distance from line instead of residuals
rng("default") t = rand(100,1); x = t/10 + randn(size(t))/10; y = 5*t + randn(size(t))/10; plot(x,y,'o') sol = fminsearch(@...

4 years ago | 0

Answered
Solution of two order differential equations; Fourth order Runge-Kutta method iteration
Running your problem with ODE45 gives your Runge-Kutta results. So the problem seems to be that your parameters are different fr...

4 years ago | 0

| accepted

Answered
How to perform linear curve fitting based on distance from line instead of residuals
The residuals are the sum of the vertical distances of the points from the line. If you want to consider the orthogonal distanc...

4 years ago | 0

Answered
PERIMETER OF A 3D POLYGON WHICH DOES NOT LIE IN THE X-Y PLANE
The code should apply to your case: x = 3*cos(0:pi/20:2*pi); y = 3*sin(0:pi/20:2*pi); fn = cscvn([x;y]); % Compute enclosed ...

4 years ago | 1

| accepted

Answered
Initial Conditions not Generating on Graph
You plot "hs" for different values of "nd". So the initial condition for hs is always the same, namely 225 mm. I don't underst...

4 years ago | 0

| accepted

Answered
Nonlinear regression using lsqcurvefit
F = @(x,f) x(1)/2 * sin(x(2)*pi/2)./(cosh(x(2)*log(2*pi*f*x(3)))+cos(x(2)*pi/2)); instead of F = @(x,f)(x(1)./2)*(sin(x(2).*pi...

4 years ago | 0

| accepted

Answered
Problem with "if" command
Should be if PBtime_nb>PBtime_b instead of if PBtime_b>PBtime_nb;

4 years ago | 1

Answered
Minimize distance between curves
Differentiating with respect to a, setting the derivative to 0 and solving for "a" gives a = sum_i (f_i*g_i) / sum_i (f_i^2) I...

4 years ago | 0

| accepted

Answered
How to make 2D matrix from 3D matrix to solve 2D nonlinear system?
The matrix you have to create and work with is a (sparse) matrix of size (125000 x 125000). The 3d matrix above (whatever it ma...

4 years ago | 1

Load more