Answered
How to evaluate a symbolic expression having `max` and `diff`?
Use max(x,0) = 0.5*(abs(x)+x) for real x. syms x1 f1 = max([0, (7*sin(4*pi*x1))/10], [], 2, 'omitnan', ~in(x1, 'real')) ...

2 years ago | 0

Answered
Curve fitting of a portion of a plot and linear equilibrium of both plots
How do I curve fit of after equilbrium points in electron temperature profile so that they both equilibriate in a single line ?...

2 years ago | 1

| accepted

Answered
How to make a local function that returns a vector
% parameters N=100; div=0.1; p=sqrt(3); q=0.5; r=2; % Initial values astart=5; bstart=0.1; % function [a,b]=fcn2(N...

2 years ago | 1

| accepted

Answered
I cannot get fplot to plot my piecewise function past an x-axis value of 5
syms t %declare a symbol voltage_values = piecewise(0<=t<=3,25,3<t<=6,0,6<t<=7,-75); fplot(t,voltage_values,[0 7]) %xlim([0 7...

2 years ago | 0

| accepted

Answered
Trying to Solve quadratic inequalities
Don't expect that MATLAB succeeds for complicated systems of quadratic inequalities. But for this simple one, it returns a solut...

2 years ago | 0

| accepted

Answered
Multivariable Integration w.r.t to 1 variable: 2nd variable is a function of 1st
If y is a function of x, your integrand equals F(y(x~))*y'(x~) dx~. Thus your integral equals integral_{x~=f_lower(x)}^{x~=f_...

2 years ago | 1

| accepted

Answered
Solving a matrix equation with fixed point iteration method
main() function main clear; clc; format long % parameters of equations: E = 1; n = 0.1; u = 0.2; % parameters of this ...

2 years ago | 1

| accepted

Answered
newton raphson methon and symbolic functions
Better differentiate your function with respect to h in advance and pass the result to "dvolume" so that you only need to substi...

2 years ago | 0

| accepted

Answered
Specify boundary conditions for each node - Thermal problem
Supply your array or matrix "Data" as an additional input to "mygfun" and "myqfun" and use interpolation to supply the values fo...

2 years ago | 0

Answered
Subs Error while using solve function
You will have to find criteria to sort out the solution you want. E.g. for real solutions only you could use syms R P = 10; e...

2 years ago | 0

Answered
I estimate my desired vector with the given code but can't when.....
As you can see, the difference between xo and the noise-added xo is quite large. Thus you can expect that the difference in the ...

2 years ago | 0

| accepted

Answered
Optimization problem with array input
You might want to try "intlinprog" with x being a binary vector with x(i) = 1 meaning: ball i is picked and x(i)= 0 meaning: bal...

2 years ago | 1

| accepted

Answered
Creating a for loop based on a condition
i = 0; tolerance = 1e-4; imax = 100; output = 1; value = ...; while abs(output-value) > tolerance && i < imax i = i + ...

2 years ago | 0

Answered
Failure in initial nonlinear constraint function evaluation. FMINCON cannot continue.
You forgot to include "RCbeamdata.xls". And you know that you fix x(2) to x0(2) if you set lb(2) = ub(2) = x0(2) ? And you mus...

2 years ago | 0

Answered
error updating function line
This code plots O(i): k=3500; m=5; c=270; a=0.75; T=1.5; w=2*pi/T; g=9.81; syms t a1=2734; a2=-6718; a3=5682; a4=-1...

2 years ago | 0

Answered
Convection-Diffusion-Reaction Equation ( 2D) with a given Constrained Optimal Control Problem
What do you want to control with which constraints and how ? Optimal control problems together with ordinary or partial differe...

2 years ago | 0

Answered
finding fit parameters between two functions
Make a function that - given tau and the parameters you want to fit - returns I_m(tau). Then look at the examples for "lsqcurve...

2 years ago | 2

| accepted

Answered
Syntax for optimization with integer and continuous variables, nonlinear equalities and inequalities?
Concerning your attempt with "ga": See the Note below from the documentation of "ga": x = ga(fun,nvars,A,b,Aeq,beq,lb,ub,nonl...

2 years ago | 1

Answered
issue with simple nested integration of several variables
The problem with integral/integral2/integral3 is always that they call your function not with scalar arguments for the independe...

2 years ago | 0

| accepted

Answered
How to use Cartesian coordinates to create Grid Surface?
If the CAD file describes the surface of the body in question, there should be a value for the elevation associated with each (x...

2 years ago | 0

Answered
Solving an integral within a partial derivative
You have to solve a second ordinary differential equation for y: dy/dt = 2*Ste * theta_f*(1-Ste/3 * theta_f + 7/45*Ste^2*theta_...

2 years ago | 0

Answered
How to use a user defined function inside the curve fitting function?
Use "lsqcurvefit". There are lots of examples under https://uk.mathworks.com/help/optim/ug/lsqcurvefit.html that show how to ...

2 years ago | 0

Answered
Why does the vectorized function give wrong result?
Compare Fun1 and Fun2. In Fun1, xo is computed using u while in Fun2, both xo and xe are computed using b. Further, the sorting ...

2 years ago | 0

| accepted

Answered
what happens behind "/"
If x = [2 3 4 5 6] and y = [3 4 5 6 7], then x/y determines the number "a" for which the error when approximating x by a*y is mi...

2 years ago | 2

| accepted

Answered
The function is debugging too long...
But the secant method is very different from your code - something like this: clc, clear all, close all x1=linspace(-pi/2,p...

2 years ago | 0

Answered
solving system of equations
I wonder what you expect as solution for 1 equation with 7 unset parameters. Say you have the equation g = x + c1 + c2 + c3 +...

2 years ago | 0

| accepted

Answered
Error using plot for Fourier series
I'm not sure what you try to do. Maybe something like this: clear all syms x L = 2; f = piecewise(x<=L/2,x,x>L/2,(L-x));...

2 years ago | 0

Answered
How to vectorize the following piece of code by removing the two for loops?
clear all;clc u=[3 4 30 50];% Desired Vector b=u; [R,C]=size(b); P=C/2; M=2*C; k = (1:M).'; i = (1:P); xo = sum(1*exp(1i...

2 years ago | 0

| accepted

Answered
how to express operators in symbolic algebra
Maybe like this syms x syms P(x) q(x) q(x) = x^2 P(x) = diff(q(x),1) + 5 ? You can't define P as a function of a dependen...

2 years ago | 0

Answered
what is different between the codes?
In both cases, you want to solve one equation in three symbolic variables (x,K,M). In your first code, MATLAB is able to determ...

2 years ago | 0

| accepted

Load more