Answered
I use the PSO optimization algorithm and I get the error Unable to perform assignment because the size of the left side is 10-by-1 and the size of the right side is 1-by-3.
The reason for the error message is obvious. You can't save a 1x3 array (actfunc(randperm(3))) in a 10x1 array (particles(:, 2))...

3 years ago | 0

| accepted

Answered
Creating a square multidimensional array from a function
x= -7:0.1:7; y= -7:0.1:7; z= -7:0.1:7; [X,Y,Z] = ndgrid(x,y,z); F = fun(X,Y,Z) size(F) function f = fun(x,y,z) f = ...

3 years ago | 0

| accepted

Answered
How to resolve this error "Array indices must be positive integers or logical values."
You forgot a multiplikation sign: t2=((f*vmax+xf*Dq*(-mum+3*m+12*(s^2))+4.5*(s^2)*(xf^2)*D2q)/(r-(3*m+3*(s^2)))); instead of ...

3 years ago | 0

Answered
fitting data with a combination of exponential and linear form ( a*exp(-x/b)+c*x+d )
Try f(x) = a*atan(b*x) It's too steep at the beginning and too flat at the end, but better than your model function. data= r...

3 years ago | 1

Answered
Linear Regression with Only Dependent Variables
The model with parameters a, b and c to be determined should be column_matrix_1 * a/sqrt(a^2+b^2) + column_matrix_2 * b/sqrt(a^...

3 years ago | 0

Answered
Making a new column from old column
x = linspace(0.1,1,17).'; y = x; y(y>0.5) = 1;

3 years ago | 0

| accepted

Answered
Boundary value problem-bvp4c
Use ode45 and integrate backwards: https://uk.mathworks.com/matlabcentral/answers/1881197-numerical-integration-backwards-for-o...

3 years ago | 0

| accepted

Answered
How do i add a changing input over a interval using ODE45?
v = 25/3.6; % Speed of the car Lslope = (0.5/v)*1000; % Length of the slope in time (assuming v is ...

3 years ago | 0

Answered
I am getting error "Index in position 2 exceeds array bounds (must not exceed 6)"
You should try [u,s,v]=svd(xi); instead of [u,s,v]=svd(xi,0);

3 years ago | 0

Answered
3D Heat Equation in PDE Solver
T_center = interpolateTemperature(results, 5,5,0.5); You didn't specify the times at which you want the temperature to be suppl...

3 years ago | 0

Answered
Visualizing 2D Slices of a 3D Shape Subject to 3D Heat Equation and Boundary Conditions
I have no experience with the PDE toolbox, but it seems from the error message that you defined a stationary, not a time-depende...

3 years ago | 0

Answered
Trying to find a solution for nonlinear ODE
The variables are ordered as [y(1) y(2) y(3) y(4)] = [p dp/dx q dq/dx]. You will have to add the boundary condition part. syms...

3 years ago | 0

| accepted

Answered
problem in for loop not working in fixed point iteration while loop
Maybe like this ? clear all load('results.mat') N_pr = 99; P_sat = Pb; P_abandon = 1700; delh_pr = (P_sat-P_abandon)/N_pr;...

3 years ago | 0

| accepted

Answered
Plotting the 3D Heat Equation in 2D Slices
Your implementation of Explicit Euler looks correct. If you want larger time steps and faster performance, use an ODE solver li...

3 years ago | 1

Answered
How to get the available solution of the singular matrix equations?
The system cannot be solved with equality because rank(A) = 68 while rank([A,b]) = 69. You can only try to find a vector x that...

3 years ago | 0

Answered
please help me modify the code i want to simulate the temperature profile distributed along the height of the adsorption column
If you don't want to save the temperatures for all time steps, you need at least two arrays T_old and T_new such that your advan...

3 years ago | 0

| accepted

Answered
Fmincon finds different solutions for optimization problem in dependance of initial values
It's not unusual that the solution for optimization problems depends on the initial guesses for the optimization variables. If...

3 years ago | 1

Answered
Integral and inverse integral
MATLAB is not able to find the inverse: syms x Sigma= 1; Mu=5; PDF_Norm=exp(-0.5.*((x-Mu)/Sigma).^2)/(Sigma*sqrt(2*pi)); a...

3 years ago | 1

Answered
Euler's identity with angle in degrees
a = 30; exp(deg2rad(a)*1i) exp(a*pi/180*1i)

3 years ago | 1

| accepted

Answered
Least squares linear regression with constraints
You made a mistake in computing the correct coefficients (see below). clear all close all x11 = [0.091, 0.068, 0.086, 0.091, 0...

3 years ago | 0

Answered
Nonlinear regression with two variables
I don't know your inputs, but theoretically, it works: X = rand(50,2); Y = rand(50,1); % Define the model function model = @...

3 years ago | 0

Answered
Accessing local variables in a function.
By defining them as output variables function [x,y] = drawHexagon(sideLength, centerX, centerY) and calling the function as [...

3 years ago | 1

Answered
How to solve a system of distributed delay equations?
As a start, you could define three delays, namely delay(1) = tau-gamma, delay(2) = tau and delay(3) = tau+gamma, and approximate...

3 years ago | 1

| accepted

Answered
How to use Jacobian option of odeset for ode15i while solving DAEs?
syms x1(t) x2(t) x3(t) m l g c; % DAE system eqn1 = diff(x1(t),t)-x3(t)==0; eqn2 = diff(x3(t),t)*sin(x1(t))-x2(t)*cos(x1(t)...

3 years ago | 0

| accepted

Answered
Symbolic simplify get wrong result
(a*b)^1/3 = (a*b)/3, not = (a*b)^(1/3)

3 years ago | 0

| accepted

Answered
Solving a complicated non-linear equation in Simulink
With suitable constants c1,...,c6 and substituting x = sin(sigma_A^EC), your equation can be written as c1*(x^2-c2) - c3*(x*c4-...

3 years ago | 1

| accepted

Answered
What is the main difference between gradient command and diff comand
gradient: 5-1,(10-1)/2,(17-5)/2,(30-10)/2,30-17 diff: 5-1,10-5,17-10,30-17 Both are approximations to the slope of x if the sp...

3 years ago | 0

Answered
Symbolically solve non-linear differential equation
You don't need to solve the equation symbolically. Just solve simultaneously the two differential equations %db2/dt=b2*(c2*(1-...

3 years ago | 0

| accepted

Answered
Solving system of four equations
syms e1 e2 e3 e4 for i=1:25 eq1=((nco+v3*e1+v22*e2+v41*e4)^2*(nh2+v4*e1+v24*e2+v33*e3)^2)-(k(i)*(n0+v*e1+v03*e3+v04*e4)^2*...

3 years ago | 0

| accepted

Answered
How to output simple linear regression confidence limits for new values of independent variable.
My guess is that your linear model has two independent variables. That's why you had to supply a two-column vector of new X-va...

3 years ago | 0

Load more