Answered
(Error using vertcat) Dimensions of arrays being concatenated are not consistent
x and y are of size 1x500, phix(:,a)' and phiy(:,a)' are of size 1x8. So either x and y had to be of size 1x8 or phix(:,a)' and ...

7 months ago | 1

Answered
Symbolic integration: error
Here is one possible implementation: syms x y r u = ((x-1+r)^2+y^2-r^2)*(y^2-r^2/(1-2*r)*x^2); du = gradient(u, [x,y]); du2 ...

8 months ago | 0

Answered
Change ode time step based on state
An easier way is to choose appropriate absolute and relative tolerances to reduce the error of the integration: options = odese...

8 months ago | 0

Answered
Odefun returns a vector of length 1, but the length of initial conditions vector is 4.
Use function ydot = noMoonGrav(t, y) instead of function [t, ydot] = noMoonGrav(t, y)

8 months ago | 1

| accepted

Answered
Symbolic calculation with solve command
Use S = solve(eqns,[k1 k2 k3],'MaxDegree',4) instead of S = solve(eqns,[k1 k2 k3])

8 months ago | 1

| accepted

Answered
Display data in a while loop as a table
clear, clc format longg f=@(x) x^3-5; df=@(x) 3*x^2; [n,X,Y] = newtonimproved_4_7(f,df,1,0.00001); t=table((1:n).',X',Y'); ...

8 months ago | 1

Answered
Constraints to a Second Order Curve Fit
x = [150, 190, 400, 330, 115, 494].'; y = [1537, 1784, 3438, 2943, 1175, 4203].'; C = [x.^2,x,ones(numel(x),1)]; d = y; lb =...

8 months ago | 0

Answered
How to express constants of integral
MATLAB's "int" only returns one possible antiderivative. If you want to show the free integration constants, you could use "ds...

8 months ago | 2

| accepted

Answered
solve set of inequalities and plot the solution
A = [-0.0664057051742095,0.0900076050430003;... 0.147476397055133,0.160063987615969;... -0.122381054306963,0.1252339...

8 months ago | 0

| accepted

Answered
Fitting exponential using derivatives
As far as I understand, your model is a differential equation dr/dt = a*1.5^(c+d)*(5-r)^c*(3-r)^d, r(0) = r0 with unknown para...

9 months ago | 0

Answered
Apply boundary condition (upper and lower limit) to parameters during the fitting using the function nlinfit?
If you restrict parameters by imposing upper and/or lower bounds, a statistical analysis of the results like that offered by "nl...

9 months ago | 0

Answered
The problem is that when I use vpa(U(x,t), 7) to get the solution with 7-digit decimal precision, MATLAB still outputs a very long and complicated expression. how do I fix it?
The documentation says xVpa = vpa(x,d) uses at least d significant digits instead of the value of digit...

9 months ago | 0

Answered
how to solve 2DOF linear time variant differential equations in matlab with non-diagonal mass, stiffness and damping matrixes
x0 = [0;0;0;0]; tspan = [0 13.28]; [T,X] = ode45(@fun,tspan,x0); for i = 1:numel(T) dxdt = fun(T(i),X(i,:)); q1ddot(i) ...

9 months ago | 1

Answered
How can I solve the problem in integral code?
Loop over the values of the sigma-vector - thus call "vpaintegral" for each sigma value separately. Or alternatively make your ...

9 months ago | 1

| accepted

Answered
Warning: Error updating FunctionLine in using fplot
In R2024b, I get the warning (see above): Warning: Function behaves unexpectedly on array inputs. To improve performance, pro...

9 months ago | 0

Answered
find sequence in a matrix
I = [0 1 0 1 1 1 0 0 0 1 1 1 0 0 1 0 1 0]; k = 3; saved = k + find(diff(I(k:end))==-1,1) If I is a matrix, you will have to t...

9 months ago | 0

| accepted

Answered
Pass Additional Arguments into Guess Function for BVP
lambda = 15; additional_parameters = 22; solinit = bvpinit(linspace(0,pi,10),@(x)mat4init(x,additional_parameters),lambda); s...

9 months ago | 0

| accepted

Answered
Solve BVP with Arrays as Coefficients
If you have functions depending on x for a, b and f, you are done. If not, you can try the following: Use "interp1" to interpo...

9 months ago | 0

| accepted

Answered
Why the integration can not be calculated out correctly?
That's the best you can get, I guess: V = 0.46:0.01:1; for i = 1:numel(V) v = V(i); lower_x = 9.578251022212591 - v; ...

9 months ago | 0

| accepted

Answered
Not exactly the exact answer using Symbolic Math Toolbox
syms t f = sin(t); frms = sqrt(1/(2*sym(pi))*int(f^2,t,[0 2*sym(pi)])) % rms value from definition

9 months ago | 1

| accepted

Answered
How to implement time dependent heat generation
I leave the rest to you: %% Create thermal model PDE thermalmodel = createpde(1); %% Create Geometry R2= [3,4,-1.5,1.5,1...

9 months ago | 0

| accepted

Answered
2 eqns in 2D with different BCs applied to each variable on the same edge? On E1, u1=0 and du2/dn=0, on E2 u2=1 and =du1/dn=0. The solution is all zeros. Example code is below
I think applyBoundaryCondition (model, "mixed", Edge=1, u=0, EquationIndex=1,q=[0 0;0 0],g=[0;0]); applyBoundaryCondition (mod...

9 months ago | 0

| accepted

Answered
Error msg: Undefined function or variable 'optimproblem'. Error in optimize_plant_operation (line 6) prob = optimproblem('ObjectiveSense', 'maximize');
"optimproblem" was introduced in R2017b: https://uk.mathworks.com/help/optim/ug/optimproblem.html at the bottom of the page un...

9 months ago | 0

Answered
Computing velocity with Forward Euler method
@Riccardo Are you sure you can leave temperature fixed with a pressure difference of 12 bar ? And did you try plotting your re...

9 months ago | 0

Answered
model non-autonomous system with neural ode
You can easily convert your non-autonomous system into an autonomous one by defining an additional ODE y2 as dy/dt = y2, y(0...

9 months ago | 0

| accepted

Answered
Orthotropic Conductivity on Face
I found orthoK = [0.75*kappa; 0.85*kappa]; in the documentation - thus a column instead of a row vector.

9 months ago | 0

| accepted

Answered
Using fprintf in a for loop to display the output as a set of coordinate points
syms x y real y=x*(4-x)^3;dy=diff(y); x_roots=solve(dy,x); y_x_roots=subs(y,x_roots); for j=1 disp('The critical point(...

9 months ago | 0

| accepted

Answered
Average Flux Across Edge
Should be averageFlux = 1/(Nodes_Xa(end)-Nodes_Xa(1))*trapz(Nodes_Xa,flux_Xa)

9 months ago | 0

| accepted

Answered
What do you think of my numerical Jacobian, using the central-difference method?
It cannot be correct because F1,...,F6 are scalars, not functions. And if F1,...,F6 were functions, the 2*h expression must be...

9 months ago | 0

Answered
How should I compute the Jacobian for my equations of motion?
According to your description, at some stage of your procedure, the right-hand side of your ODE system is available as a symboli...

9 months ago | 0

| accepted

Load more