Answered
Getting an error "Matrix dimensions must agree" in my matlab program.help
repmat(N,3,1) has three elements, repelem(ez,3,1) has four elements. So matrix dimensions don't agree. Best wishes Tor...

8 years ago | 0

Answered
fmincon after solve error
fun = -solve(eqn,gamma); [pilotPowerOpt,fval] = fmincon(@(x)myMatlabFunction(x(1),x(2)),x0,A,b);

8 years ago | 1

| accepted

Answered
Find the position of a minimum in an array
a=[ 3 4 2 6 0 9 ; 3 5 8 2 5 9]; [min_val,idx]=min(a(:)); [row,col]=ind2sub(size(a),idx)

8 years ago | 0

| accepted

Answered
Numerical Integration and Approximation
x = linspace(1,10,3); fx = x.^2.*exp(x); I = trapint(x,fx)

8 years ago | 0

Answered
How can I turn this Explicit method code to Implicit method code ?
L = 1; % Length of modeled domain [m] nx = 200; % Number of gridpoints t = 500; % t...

8 years ago | 0

Answered
How to force a exponential fit to go through a preestablish point (x,y)?
x0 = ...; % x coordinate of preestablished point y0 = ...; % y coordinate of preestablished point g = @(p,x)y0*exp(-p...

8 years ago | 2

| accepted

Answered
Writing a code for symbolic integration
Setting C1 = (T_i-T_inf)*(-C1*lambda_1/r0)*J1(lambda_1*r0/r0) C2 = lambda_1^2*alpha/r0^2 your function is f(t)...

8 years ago | 0

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

Load more