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

Answered
Simplify matrix of symbolic equations
syms x1 x2 f1 f2 f1 = x1 + x2 == 1; f2 = 2*x1 + 3*x2; x1s = solve(f1,x1); f2 = subs(f2,x1,x1s)

4 years ago | 0

Answered
Analytical solution of symbolic equation
The term L^a in eqn2 prevents that it is solvable for L. If you specify a as 1/2, 1/3, 1/4, 1, 2, 3, 4, e.g. eqn2 is a polynomi...

4 years ago | 0

| accepted

Answered
fsolve giving error that solution is not finite and real. When I test using vpasolve() I get a solution, then I input the same solution and get same error of not finite/real.
c1 = 0.5176; c2 = 116; c3 = .4; c4 = 0.4; c5 = 5; c6 =21; c7 = .08; c8 = .035; syms lambda for k = 1:600 theta = p...

4 years ago | 0

Answered
ode45 errors in integration
Try setting RelTol and AbsTol to smaller values than the defaults: options = odeset('RelTol',1e-6,'AbsTol',1e-8); [z,r] = ode4...

4 years ago | 0

| accepted

Answered
Not getting finite result
syms theta syms z K L=40; lambda=0.532*10^(-6); a=10*(lambda*L)^0.5; A=1; n=0; m=0; k=2*pi/(lambda); e =(k*a)/((k*a^2)...

4 years ago | 0

| accepted

Answered
Solving system of ODE's with one dependant algebraic equation
When executing the code, na becomes NaN relatively soon: clc; clear; %Gaussian photon pump intensity FWHM = 9; sd = 2.355*FWH...

4 years ago | 1

| accepted

Answered
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side. Can anyone please help, Thanks in advance.
muo(i) = (-1./u).*log(((d1.^m)./(a.*n.*PsByN_0(i).*T.*u+d1.^m).*a)./(1-a)); instead of muo(i) = (-1./u).*log(((d1.^m)./(a.*n.*...

4 years ago | 0

| accepted

Answered
how to reduce the size of a matrix?
n = 4; A = rand(n,n); A_reduced = zeros(n/2,n/2); for i=1:n/2 for j=1:n/2 Ahelp = A(2*(i-1)+1:2*i,2*(j-1)+1:2*j...

4 years ago | 0

Answered
(Matrix Optimization) Optimization method for coefficient matrix in Ax = b with known x and b.
If x1, b1, x2, b2 are your given data, use x1 = [2 7 56 -3]; b1 = [12 -4 0.23 pi]; x2 = [-5 23 9.5 12]; b2 = [0.43 2.4 -12.6...

4 years ago | 1

| accepted

Load more