Answered
Curve fitting of transcendental equation with lsqcurvefit
Xdata=GWM_viscosity'; Ydata=GWM_f_out'; predictedzeros = @(x) Ydata + sqrt(k_val)./sqrt(m_canti_val+x(2)*B_val*Gap_val*L_val...

4 years ago | 0

| accepted

Answered
How to introduce a constraint and stop condition in ode45 ?
First question: You can't prescribe a constraint for a solution variable of an ODE. The ODE variable results automatically from...

4 years ago | 2

| accepted

Answered
Array Operations give me a constant
D0 = 100; D1 = 80; D2 = 80; HD = 0.4; A = -6.96*log(D1/D2)/D0; % A is 0 for symmetric bifurcations B = 1 + 6.98*(1-HD)/D0; ...

4 years ago | 0

| accepted

Answered
simplifying an algebraic expression in 6 variables
fun = @(x) sum( (y - A.'*x - K*sqrt((B.'*x).^2 + (C.'*x).^2) ).^2 ); Aeq = ones(1,6); beq = 1; lb = zeros(1,6); ub = ones(1,...

4 years ago | 0

| accepted

Answered
Solving the linear equation
M = T*P.'*inv(P*P.') is the least-squares solution. But you cannot expect that T=M*P is exactly satisfied.

4 years ago | 0

Answered
Implementing vectorial equation with matrix as variable
c^(D*i) is a 2x2 matrix. Thus [a0;b0]*c^(D*i) is not defined. Maybe you mean c^(D*i)*[a0;b0] or [a0,b0]*c^(D*i) ? I implemented...

4 years ago | 0

| accepted

Answered
Finding the index of elements of a vector in a mesh quite fast
mesh=linspace(0,10,10^6); A=0+(10-0).*rand(1,10000); N=1000; tic; for n=1:N y = discretize(A,mesh); idx = A-mesh(y) ...

4 years ago | 0

| accepted

Answered
Curve Fitting Toolbox with multiple variables
lsqnonlin and lsqcurvefit allow to prescribe lower and upper bounds (lb,ub) on the parameters: x = lsqnonlin(fun,x0,lb,ub,optio...

4 years ago | 1

| accepted

Answered
How can I change this code to euler backward method? (implicit method)
f = @(t,y) -100000*y + 99999*exp(-t); t0 = 0; y0 =0; h = 0.01; tn = 2; n = (tn-t0)/h; t(1)=t0; y(1)=y0; ...

4 years ago | 0

| accepted

Answered
Something wrong in the plotting
Only the continuous line is visible in Release R2022a. V1 = @(r,w) -acosh(10*(w./(1600*r + 21)).^(1/2))/20000000000; V2 = @(r,...

4 years ago | 0

Answered
Code gives Loop function error
t = 0:0.1:0.5; F = 500 - 1000*t;

4 years ago | 0

Answered
reversing the lookup table for flux based pmsm modelling, how to reverse the data Ψd(id,iq) , Ψq(id,iq) into id( Ψd, Ψq) and iq( Ψd, Ψq).
Use "fsolve" to solve for id, iq given psi_d, psi_q. In other words, solve the two equations psi_d(id,iq) - psi_d_given = 0 p...

4 years ago | 0

Answered
Array indices must be positive integers or logical values.
if rand < prob_prod % Defines whether production takes place based on Monte Carlo method. x_nr(t_nr)=x_nr(t_nr-1)+1; % Impl...

4 years ago | 0

Answered
How can I interpolate data obtained from two different time intervals?
load_fine = interp1(t_coarse,load_coarse,t_fine) where t_coarse is the time vector for the load data and t_fine is the time vec...

4 years ago | 0

Answered
How to choose an element from a vector with not equal probabilities?
A=[10 70 30 100]; P=[0,cumsum(A)/sum(A)] R = rand(10,1) Y = discretize(R,P) Rand = A(Y)

4 years ago | 0

| accepted

Answered
Why doesn't my figure show?
a=0; b=0.5; m=0.2; v=0.5; pi=0.02; f=zeros(1,20); p(1)=0.01; for i=2:20 if i<=5 f=0.04; elseif 6<=i ...

4 years ago | 0

| accepted

Answered
Equalising the number of points in a graph
X = sort(union(xgraph1,xgraph2)); ygraph1 = interp1(xgraph1,ygraph1,X,'linear','extrap'); ygraph2 = interp1(xgraph2,ygraph2,X,...

4 years ago | 1

| accepted

Answered
How to input multiple value of 'lbar' like 0.1, 0.2 , 0.3 and multiple value of 'sigma' like 0.1, 0.15, 0.2 to obtain multiple output values of W?
% For plane slider: H = Ho + a(1-x) Ho = 1; alpha = 0.1; eps = 0.1; a = 1.0; LBAR = 0.1:0.01:0.3; SIGMA = 0.1:0.01:0.2; r...

4 years ago | 0

| accepted

Answered
After this I want to integrate P1 from 0 to x (let's say this function to be P2) and then again integrating the function P2 from 0 to 1. I don't know how to proceed.
% For plane slider: H = Ho + a(1-x) Ho = 1; alpha = 0.1; eps = 0.1; a = 1.0; lbar = 0.1; sigma = 0.05; H = @(x) Ho + a*(1...

4 years ago | 0

| accepted

Answered
Three nonlinear equation with initial guess
fun = @(x,y,z)[-0.06*(x^2)-1.06*(z^2)+3.18*x+3.18*z+1.59*y-2.06*x*y-3.12*x*z-2.385-1.06*y*z;2.63*(x^2)-1.63*(y^2)-2.63*(z^2)-3.9...

4 years ago | 1

Answered
plot a surface for g-f=0
The "surface" f-g = 0 is a one-dimensional manifold in the y/z - plane and you get the corresponding curves using the "fimplicit...

4 years ago | 0

Answered
How to apply gradient metod to a single variable optimization problem
As you can see, without giving values to Cp, Cs, tau, Kp, Kop and Kr, you cannot solve for the critical points of Jd since you h...

4 years ago | 0

| accepted

Answered
how can i repeat the function using iteration
MAXRWRD = -Inf; itermax = 30; iter = 0; while MAXRWRD < 30 && iter < itermax iter = iter + 1; D = zeros(size(L)); ...

4 years ago | 0

Answered
Difference between spline(x,y,xq) and interp1(x,y,xq,'spline')
https://de.mathworks.com/matlabcentral/answers/195649-fast-interp1-with-spline

4 years ago | 0

| accepted

Answered
heat equation pde is subject to the initial conditions at t=0 and to nonhomogeneous Neumann boundary conditions. i have mistake in finding the error vector as function of time
%Implementation of FTCS for 1-D paracolic problem with NN boundary conditions % u_t-cu_xx=f(x,t), % where a<x<b and t>...

4 years ago | 0

Answered
How to generate a matrix with random numbers between 0 and 1 and mean of the distribution is unspecified.
If you choose the number of random numbers large enough, their mean should approach 0.5: n = 20000; y = rand(n,1); ym = mean(...

4 years ago | 0

Answered
Nonlinear Data-Fitting
% Prescribe arrays K = ...; X = ...; L = ...; Y = ...; % Define function fun = @(a,b,c,d,h) K.*log(a./(a-X)) + K/b.*log(X/...

4 years ago | 0

| accepted

Answered
Error "Supplied objective function must return a scalar value."
The function you pass to fmincon returns a vector of values, not a scalar. Maybe you mean f=@(a) norm(sum(((a(1).*(G(x,:)+m)+...

4 years ago | 0

| accepted

Answered
Problem writing fminsearch function
Here is a solution without optimizers: % Define lower and upper bounds for P1, P2 and P3 lb1 = 2000; ub1 = 4000; lb2 = 2000;...

4 years ago | 0

| accepted

Answered
Save the values in if-else
for n=1:length(week) if myorder(n)>=30 ordercost(n)=(myorder(n))*(60-(0.1*60)); else ordercost(n)=(m...

4 years ago | 0

| accepted

Load more