Answered
How to load intermediate variable into workspace while using ode45 ?
tspan = 1:200; x0 = zeros(38,1); [t,x] = ode45(@system, tspan,x0); ts=40; ssActive = [1,2,3,4,1,3,4,2,4,3,3,4,3,3,1,2,3,4,1,...

4 years ago | 0

Answered
[f,x]=ecdf(y) definationf of x
https://de.mathworks.com/help/stats/ecdf.html There are six literature reference at the bottom of the page. Usually, the minim...

4 years ago | 0

| accepted

Answered
trying to use the fmincon function
Works for me after changing "fun" in "@fun": % script calling fmincon start clc clear all x0=[-1...

4 years ago | 0

| accepted

Answered
How to generate all possible vectors where each element can take one of two values
Generate all possible combinations of 0 and 1: m = 3; justRows = dec2bin(0:2^m-1)-'0' Now replace the 0's by a(i) and the 1 b...

4 years ago | 1

Answered
Local minima of an interpolant fit
Pass the evaluating function for the interpolant as objective function to fminsearch or another optimizer (fmincon,...). E.g. ...

4 years ago | 0

Answered
How can plot 1D manifold in 3d space
syms x y z p=0.255*z.^2./(z.^2+(0.055)^2); m1=0.15^2./(p.^2+0.15^2); m2=z.^4./(z.^4+0.1^4); m3=p.^2/(p.^2+0.15^2); g = 0.05...

4 years ago | 0

| accepted

Answered
How to create a function that can work out an input provided the output and and all other variables are known?
Use "fzero" or "fsolve" to solve G(x) := f(L1,l1,h1) - f(random L2, x, random h2) = 0 for x.

4 years ago | 0

| accepted

Answered
Workaround for the expinv function in statistics toolbox
p = 0.3; mu = 1/4; x = -mu.*log(1-p) x2 = expinv(p,mu)

4 years ago | 0

| accepted

Answered
Creating a matrix for a function
A = [ones(numel(t),1),sin(t),cos(t),sin(2*t),cos(2*t)]

4 years ago | 0

| accepted

Answered
slightly off euler method code
f = @(t,y) exp(t) - t; fSol = @(t) exp(t) - t.^2/2; [t,y]= eulerMethod(f,0.2,2,0,1); plot(t,y) hold on plot(t,fSol...

4 years ago | 0

| accepted

Answered
How to numerically integrate the planar equations of motion?
syms V(t) a1 a2 sol = dsolve(diff(V,t)==a1*V^2+a2) Now substitute a1 = -rho/(2*beta) and a2 = -g0*sin(gamma)

4 years ago | 0

Answered
Why am I not getting desired output?
h = 0.05; t = 1:h:500; y0 = [2.5, 3.6, 9.5, 8.8, 2, 3, 7, 7.5]; % t(1) =0; y = zeros(length(t),8); y(1,:) = y0; for i = 1:...

4 years ago | 0

| accepted

Answered
Why does matlab not evaluate equations properly?
syms x f = log(0.7*x+0.5); x_0 = 4.2857; t0 = taylor(f,x,x_0,'Order',2); h = matlabFunction(t0); h(6.42855) log(0.7*6.4285...

4 years ago | 0

Answered
solve a forced vibration equation for x and w
https://de.mathworks.com/help/symbolic/eig.html First multiply by M^(-1) = [1/(3*m) 0; 0 1/m]

4 years ago | 1

Answered
recur.m function
Works for me. a = 1:10; %N=10 b = 1:5; %M=4 n = 11:25; x = 11:25; x0 = 3:6; y0 = 1:10; y = recur(a,b,n,x,x0,y0) f...

4 years ago | 0

Answered
dsolve gives wrong equations?
There are often several ways to write a function. But it seems to me that your S2 solutions are not independent. syms y(x) C1 ...

4 years ago | 0

| accepted

Answered
Solving a System of Trig Equations
Use the symbolic toolbox to solve the last equation for cos(theta1). It's a polynomial equation of degree 4 which will have 4 r...

4 years ago | 0

Answered
Optimization of Logistic Function Variable K for multiple Inputs Simultaneously
I think you will have to work on the approximation function "fun" in order to get better results. promAngles = [146.7589 115.7...

4 years ago | 1

| accepted

Answered
How to stop ODE fuction in a certain value
Better you use the Event facility of the ODE integrators. Note that your results become complex-valued because y(4) becomes gre...

4 years ago | 0

Answered
How to solve and store a system of non-linear equations with an array of outputs?
Taking cotd on both sides of the second equation gives cotd(dRF)-cotd(dLF)=Ap*w/L; cotd(dRF)+cotd(dLF)=2*cotd(davg(i)); Thus ...

4 years ago | 1

| accepted

Answered
Optimize transition rate matrix
Instead of a 4x4 matrix use a (16x1) vector. Then it is easy to implement your constraints in Aeq and beq. If somewhere in your...

4 years ago | 0

| accepted

Answered
Suggestions on solving this complex-vector-nonlinear system of equations in MATLAB
This is a simple linear system of equations in the unknowns W and Z: alpha2 = 205*(pi/180); alpha3 = 55*(pi/180); beta2 = 39*...

4 years ago | 0

| accepted

Answered
Intersection of two curves in matlab
clc %crate=0:1:10; G=-I_BT; h=4000;%no. of cycles T=30+273;%temp in kelvin R=8.314;%universal gas const capa=200;%battery ...

4 years ago | 0

Answered
Polyfit and Polyval on Reduced Matrices
You are aware that you fit parameters a and b of the function f(x) = a + 10*b*log10(x) to your data vector y ? Did you try f...

4 years ago | 0

Answered
Attempting to Plot In A Specific Range
x1 = (linspace(-3.5,3.5,numel(y))).'; plot(x1,y,'-')

4 years ago | 0

Answered
Itterate over array in steps of 120.
r=readmatrix('data_jong_edit.txt'); r(isnan(r(:,1)),:)=[]; empty = nan(16800,2); r = [r empty]; u=unique(r(:,1)); for k=1...

4 years ago | 0

| accepted

Answered
Double "for loop" with an integral of hundle functions, problem.
f=@(t)[-7*t+25 %insert (by copy and paste), in the [ ], 10 functions. (Copy %from another software) 140*t+-122 10...

4 years ago | 0

| accepted

Answered
What happen to this loop?
a=0; t=1; while t==1 a=a+0.01; if a >= 0.5 t=0; end end a t %why it only break loop when a=a+...

4 years ago | 0

| accepted

Answered
Some basic MATLAB questions
n = 20; r = zeros(n,1) for i=1:n r(i) = rand; if r(i) < 0.25 quarter(i) = ... elseif r(i) >=0.25 && r(...

4 years ago | 0

Answered
For Loop How to use previous calculated value in next iteration
PercentageIntervalTimes = StartTime + (1:length(Time))*(PercentageTimeLeft * 10); No loop needed.

4 years ago | 0

| accepted

Load more