Answered
How to plot a function obtained after integrating a two-parameter function with respect to one parameter?
y=0:0.01:1; f=@(t,y) exp(-t*y); q=integral(@(t) f(t,y),0,2,'ArrayValued',true); g=@(t,y) sin(t*y); p=integral(@(t)...

8 years ago | 1

Answered
how to code a matrix A, such that A = [aij ] is defined by aij = max(i, j)
A loop is the easiest way to define your matrix, I guess: A = zeros(n); for i = 1:n for j = 1:n A(i,j) = max...

8 years ago | 0

Answered
How can I fit the roots of a polynomial function?
Use lsqnonlin with fun = @(k)ydata.^3+(1-k(1)*xdata).*ydata.^2+2*ydata+1. Best wishes Torsten.

8 years ago | 0

Answered
How to do a Four Parameters logistic regression fit without the Curve fitting toolbox?
function main X = [0.000; 0.012; 0.023; 0.047; 0.094; 0.188; 0.375; 0.750; 1.500; 3.000; 6.000; 12.000]; Y = [0.034;...

8 years ago | 3

| accepted

Answered
ode solver error, too many argyments etc
options = odeset('RelTol',1e-7,'AbsTol',1e-8); [t,y] = ode15s(@(t,y) rhs(t,y, k_S0_S1, k_S2_S3, k_S7_S8, k_S9_S10, k_S5_S6a...

8 years ago | 2

Answered
how to formulate if statement for a vector?
if A<=0 & B<=0 ... elseif A<=0 & B>=0 ... elseif A>=0 & B<=0 ... elseif A>=0 & B>=0 ... end

8 years ago | 1

| accepted

Answered
Smallest value for n in Leibniz Formula for Pi
a = 0; rel_error = 1.0; n = 0; while (rel_error > 1.0e-6) a = a + 4*(1-2*mod(n,2))/(2*n+1); rel_error = abs...

8 years ago | 0

| accepted

Answered
Power Series with coefficients as optimization parameters inside the nlcon
You want to fit a polynomial to a number of (x,y)-data ? Why not just using "polyfit" ? Or polyfitn if constant and linear t...

8 years ago | 1

Answered
How can I set bounds for coefficients for a custom equation in the curve fitting tool?
Set d=d c=d+p1^2 b=d+p1^2+p2^2 a=d+p1^2+p2^2+p3^2 in your custom equation and solve the fitting problem using d...

8 years ago | 0

Answered
Error using fminbnd function
Convert vDS_ via "matlabFunction" to a numerical function handle before calling "fminbnd".

8 years ago | 1

| accepted

Answered
Matrix showing all combinations of multiple dice roll
https://de.mathworks.com/matlabcentral/fileexchange/10064-allcomb-varargin Best wishes Torsten.

8 years ago | 2

Answered
Could someone help me identify why my for loop is not working?
d=[0 1; 0 0; 1 1; 1 0; 0 1; 0 0; 1 1; 1 0] x1=d(:,1); y1=d(:,2); p=1*(x1==0 & y1==0) + 2*(x1==1 & y1==1) + 3*(x1==1 &...

8 years ago | 2

Answered
assemble global stiffness matrix
k1 = [1 -1; -1 1]; k2 = k1; K = zeros(3,3) K(1:2,1:2) = k1; K(2:3,2:3) = K(2:3,2:3) + k2; K

8 years ago | 3

Answered
Hi , I have a problem with phase plot for Fourier series coefficients for periodic function exp(-t/2) , why phase plot is not odd function ?
q3= integral(fun3,a,b,'ArrayValued',true); instead of q3= integral(fun2,a,b,'ArrayValued',true);

8 years ago | 1

| accepted

Answered
How do I convert the (n, n) matrix to a (nxn,1) vector? Any suggestions?
A = [1 2; 3 4]; A = repmat(A,size(A,1)^2,1)

8 years ago | 0

Answered
Solution of spring mass system with cubic stiffness
function main m=1; c=1; k=10; k2=20; k3=20; tspan=[0 10000]; y0=[0;1]; f=randn(10000,1); tf = linspace(ts...

8 years ago | 0

| accepted

Answered
normpdf and integral: non-scalalr arguments must match in size
Does it make sense to integrate the pdf's over the standard deviation ? In any case: Try func=@(x)prod(normpdf(samps,...

8 years ago | 0

Answered
Solution of spring mass equation with cubic stiffness
function main tf = ...; % times for f-vector f = ...; % f vector tspan=[0 10000]; y0=[0;1]; [t,y]=ode45(@(t,...

8 years ago | 0

Answered
I want to end ode45 at a particular point for a DAE system in which the end point was based on 1 of the vectors. I am not able to call the vector in the Events function to terminate the solver. Is there a way to solve it?
f = @(t,x) [(-0.01725*exp(-2660*((1/x(2))-(1/300))))*x(1)*x(1);((1250*0.01725*exp(-2660*((1/x(2))-(1/300))))*x(1)*x(1))]; o...

8 years ago | 0

Answered
How to generate numbers from probability mass function?
n = 30; X = zeros(n,1); x = rand(n,1); X(x <= 0.5) = 10; X(x > 0.5 & x <= 0.8) = 7; X(x > 0.8) = 3;

8 years ago | 0

| accepted

Answered
How to calculate roots of the transcendental equation , -K_n*gtan(K_n)= 5, where n= 1,2 ,3,4....g=gavity=9.81
N = 20; w = sqrt(5); g = 9.81; f = @(x) w^2 + g*x.*tan(x); for i = 1:N x0 = [(2*i-1)*pi/2+0.1, (2*i+1)*pi/2-0.1]; y(...

8 years ago | 0

| accepted

Answered
Inner matrix dimensions must agree. my code is giving this error , can someone help me fix this
Use P = (-1i*conj(E1).*E1.^2.*w1*deff)/(c*n2*Dk)+ 1i*2*pi*(n2*I0)*(Lnl/L)*((abs(E1)).^2).*E1 +... + 1i*4*pi*(n2*I0)*...

8 years ago | 0

| accepted

Answered
How to replace ode45 with Eulers method?
... % Solve differential equations using ode45 [t,y] = euler(@FNode,tSpan,y0,K); ... function [tsol, ysol] =...

8 years ago | 0

| accepted

Answered
Error in non-linear regression
t = readtable('ban1.csv') sea = t(:,2) sst = t(:,3) at = t(:,4) A = [ones(numel(sea),1),sst,at]; rhs = sea; ...

8 years ago | 0

Answered
Provide gradient for fmincon when the function to minimize uses ODE
Look up "sensitivity equations for ordinary differential equations". The solution of these equations give you the derivative ...

8 years ago | 0

Answered
I would like know if there is a function inverse for calculate DHT^-1
DHT^-1 = 1/N * DHT https://en.wikipedia.org/wiki/Discrete_Hartley_transform Section "Properties".

8 years ago | 0

Answered
Solving non-homogeneous differential equation
Take a look at the example "ODE with Time-Dependent Terms" under https://de.mathworks.com/help/matlab/ref/ode45.html ...

8 years ago | 1

Answered
How can I solve the mass balance with both dependence time and space?
Solution is C(z)=5, if z<=t*v, C(z)=0 else.

8 years ago | 0

Load more