Answered
Need to contour plot from an Nx3 matrix with first 2 columns as points on X-Y plane and the 3rd column as the values to be plotted. I'm getting Z must be at least a 2x2 matrix
See https://de.mathworks.com/help/matlab/math/interpolating-scattered-data.html Section Interpolating Scattered Data Using gr...

4 years ago | 1

Answered
Adding delay to a system of differential equations using the Heaviside function
tau = 1.0; fun1 = @(t,y) y(1); tstart = 0.0; tend = tau; tspan = [tstart,tend]; y0 = 1; [T1,Y1] = ode...

4 years ago | 0

| accepted

Answered
How can I set bounds for ga that change with the values of the optimization variables?
Instead of using the array lb and ub, you will have to prescribe such bounds that depend on the solution variables in the Constr...

4 years ago | 0

Answered
double for loop and integral
m=1.24; w_n=55; w=0.7*w_n; zeta=0.05; td=2*pi/w; P_0=1; t=[0:0.1:100]; for ii=1:length(t) f_t(ii)=2*P_0*t(ii)/td; ...

4 years ago | 0

Answered
Error in inline expression
f = @(h) 8*abs(9*acos(3 - h/3) - (3 - h).*sqrt(6*h - h.^2)) - 100 or f = @(h) 8*abs(9./cos(3 - h/3) - (3 - h).*sqrt(6*h - h.^2...

4 years ago | 0

Answered
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
h=3600; A0=1; B0=3; P0=0; K=5*10^-5; Yb=1; Yp=0.15; t = 0:0.1:10; fyt = @(t,y) [(-K*y(1)*y(2)); (-Yb*(K*y(1...

4 years ago | 0

Answered
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
Y(1) is a scalar (single number), 1:numel(t) is a vector. You can't set a scalar to a vector. Use an unused variable name inste...

4 years ago | 0

Answered
Choice of algorithm for mixed-integer-continuous variables optimization problem
I'd call fmincon 199 times for k=2,3,4,...,200 and choose the result for K which gives a minimum for the cost function.

4 years ago | 0

Answered
Simple operations with vectors
dist(i) is one single number (a scalar), vp(i)*t is a vector of the same length as t. You can't assign a vector to a scalar ele...

4 years ago | 2

| accepted

Answered
Why am i getting length(x) as 11 instead of 16?
If you display length(x1) the answer should be 16.

4 years ago | 0

Answered
I want to code a recursive production line with input and output as arrays. I have code for scalar values, but how to switch to arrays?
Turn your script into a function, interprete your multiproduction as n single productions and call the function from above in a ...

4 years ago | 0

Answered
multiply with a vector inside for loop
% finding a_x, a_z, x_z, a_xn, display after each iteration, after each % loop, like excel :-) n = [6 5 4 3 2 1 0]; SF = [1 4...

4 years ago | 1

| accepted

Answered
Solve set of equations with multiple variables where one is time depended
You might try a numerical solution: f1 = @(x2,y2,phi2,phi3,t) x2 - 4*cos(2*pi*t) - 3*cos(phi2); f2 = @(x2,y2,phi2,phi3,t) y2 -...

4 years ago | 1

Answered
Solve set of equations with multiple variables where one is time depended
syms t phi2 phi3 x2 y2 eqn1 = x2 - 4*cos(2*pi*t) - 3*cos(phi2) == 0; eqn2 = y2 - 4*sin(2*pi*t) - 3*sin(phi2) == 0; eqn3 = 4 -...

4 years ago | 1

Answered
How to manually perform linear regression from scratch
This is the code for the manual fit: A = [ones(size(reg1(idx))),reg1(idx)]; b = reg2(idx); % linear fit equals reg2(idx)_fitt...

4 years ago | 0

| accepted

Answered
Simultanous curve fitting to multiple datasets
x1 = 0:0.1:1; x2 = 0.05:0.1:0.75; fun = @(x,a,b,c,velocity) a+b*x+velocity.*exp(c.*x); a_hat=1; b_hat=1; c_hat=1; y1 = fun(x...

4 years ago | 0

| accepted

Answered
deviation from the average value less
[m,i] = min(vecnorm(veT-mean(veT,2)))

4 years ago | 0

| accepted

Answered
how to take cube of double array?
z=y.^3

4 years ago | 0

| accepted

Answered
Saving values of a variable in while loop
errorVal(n) = sum(error(:))/((nx-2)*(ny-2));

4 years ago | 0

Answered
Matrix in matlab equation
Y = repmat(A,1000,1)

4 years ago | 0

| accepted

Answered
How to track 3 parameters with this code
k4 = dt*vossFNint(xx+k3,z(n),a(n),b(n),c(n); instead of k4 = dt*vossFNint(xx+k3,z(n)),a(n),b(n),c(n); Further I don't underst...

4 years ago | 0

| accepted

Answered
Find roots of a function with multiple inputs
And you want to solve for d ? syms d Mx tw tf b y = sym('355')/Mx*(d^2*tw/sym('12')+tf^3*b/sym('6')+tf*b*(d+tf)^2/sym('2'))-d/...

4 years ago | 0

Answered
3D Interpolation with 2 dependent function values
Unfortunately, it seems like that the required tilts (alpha and beta) are dependent on each other, which means that two separate...

4 years ago | 0

| accepted

Answered
System of equations with array inputs
function main %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%...

4 years ago | 1

Answered
How to write an 'if' script that changes a function depending on x?
function y = funk(x) if x <= 3 y = sin(x); elseif (x > 3) && (x <= 7) y = atan(x); else y = exp(-x); ...

4 years ago | 0

Answered
What is wrong with my code?
R = 8.314; T1 = 60 + 273.15; PvapH = .7583; PvapT = .3843; HvapH = 29000; HvapT = 31000; P = .7; fPva...

4 years ago | 0

| accepted

Answered
Solving System of Equations with Symbolic Toolbox
Say you want to solve eqn1 = expr1 == 0; ... eqnn = exprn == 0; Then according to what you are trying to do you can proce...

4 years ago | 0

| accepted

Answered
Problem adding delay to dde23 model
lags = [1 0.2]; a = 5; tspan = [0 5]; sol = dde23(@(t,y,Z)ddefun(t,y,Z,a), lags, @history, tspan); plot(sol.x,sol.y(1,:),'-o...

4 years ago | 0

| accepted

Answered
How do I properly subtract two column vectors of class 'Double'
You calculate v = A*x - 1 in words: A*x - one instead of v = A*x - l in words: A*x - el

4 years ago | 1

Answered
How to efficiently delete rows from very large matrix
data(any(isnan(data),2),:) = [];

4 years ago | 0

| accepted

Load more