Answered
Get array of elements based on occurrences of another vector
y=[0;1;2;3;4]; x=[1;1;2;2;2]; z{1} = y(x==1); z{2} = y(x==2); z{1} z{2}

4 years ago | 1

| accepted

Answered
Divergent solution using ode45
We don't know the reason - technically, your code is correct. Although I would change it as shown below. What makes you think t...

4 years ago | 1

Answered
Interpolation for 2 dependent output data
Why is there an 181x2 double matrix for each input value ? If there are only two doubles for each input, first use interp1 for...

4 years ago | 0

Answered
I have a csv file (2 variables) saved to my computer and all I want to do is import it to matlab and plot it - how do I do this (sorry I am a beginner)?
One of these methods should work, I guess: https://de.mathworks.com/matlabcentral/answers/72545-how-to-import-csv-file-in-matla...

4 years ago | 0

Answered
plotting graph for Equation with constraints
Use (y.^2)+(x.^2)=1 ((x.*y).^2)+(-P).^2=1 to write x,y as functions of P. Then insert these expressions in T = P.*x+1.5*x....

4 years ago | 0

Answered
adding or subtracting depending on the number
rng ("default") amount = 0.5; variable = 5; number = 1; r = rand; if r >= amount variable = variable - number; else ...

4 years ago | 0

Answered
plotting graph for Equation with constraints
Use (y.^2)+(x.^2)=1 ((x.*y).^2)+(-P).^2=1 to write x,y as functions of P. Then insert these expressions in T = P.*x+1.5*x....

4 years ago | 0

Answered
Finding root of nonlinear functions
f = @(y)(y-0.8193318913*tanh(y)).*(0.7500000000e-3*y.^2-0.1622336517e-1)+0.2931044702e-2*tanh(y); fun = @(y)f(y)./(0.7500000000...

4 years ago | 2

| accepted

Answered
Constrained linear least-squares problems, with unknowns in multiplier matrix
You must use a nonlinear optimizer (in this case: fmincon) because products of the parameters to be estimated are involved (b*V,...

4 years ago | 0

| accepted

Answered
Mulitpling diffrent scalars to diffrent numbers in a matrix
Check your resulting vector. According to your rules, it is wrong. v = [1 6 3 17 30 7 10 4 25 27]; s = 17*ones(1,numel(v)); s...

4 years ago | 0

Answered
Integration of a vector inside function for ode45
In the code below, x(3) = integral_{tau=0}^{tau=t} -0.01*x(1) dtau t=0:0.01:10; in=pi/2; indxdt=0; [t,x]= ode45(@(t,x) slmc(...

4 years ago | 0

| accepted

Answered
Gradient Descent Implementation on a function, as opposed to an equation
Use fun = @(x)ErrorFunction(x(1),x(2),x(3),x(4),x(5),x(6)) as the function handle you work on in the steepest decent.

4 years ago | 0

Answered
How to not use for loop
function dfdx = ddx(f, h) dfdx = gradient(f,h); end

4 years ago | 1

Answered
Surface data cloud fitting to even asphere model
% your data x = ...; y = ...; z = ...; p0 = [...]; % initial guess for R and kappa p = lsqnonlin(@(p)fun(p,x,y,z),p0) ...

4 years ago | 0

| accepted

Answered
my limits wont work
syms x lim1= [nthroot(x^6+8,3)/4*x^2+nthroot(3*x^4+1,2)] limit(lim1,x, Inf)

4 years ago | 0

Answered
Output is giving me Empty sym: 0-by-1
f=1995.26; z=71440; seta=-77.04; syms c R; eqns = [ tand(seta) + 1 / ( 2 * pi * f * c * R ) == 0, z^2 - 1 / (R^2 + ( 2 * pi...

4 years ago | 0

| accepted

Answered
What is the best function of the following shape?
x = -2:0.01:2; plot([x,x(end)],[1/pi*atan(2*x)+1/2,1/pi*atan(2*x(1))+1/2]) xlim ([-3 3]) ylim ([0 1])

4 years ago | 2

Answered
Plotting a function that performs a sum.
f = @(x,y,z) sum(sin((3:15).*sqrt(x*y))+z); x = linspace(0,1,100); y = 0.5; z = 0.1; plot(x,arrayfun(@(x)f(x,y,z),x)) But i...

4 years ago | 1

| accepted

Answered
symbolic function of a symbolic vector variable
y = [-1, 2, -1]; syms f(z) z = sym('z',[1 3]); f(z) = y + z f(1,2,3)

4 years ago | 0

Answered
How to constrain the resulting equation from a polynomial surface fit to a positive range?
Use "lsqlin" and put the constraints p33(x(i),y(j)) >= 0 for all (i,j)-combinations. These constraints can be put as A*coeffs...

4 years ago | 0

Answered
4 Nonlinear equations solve for 4 variables
%Initial guesses E1o = 0.00009; E2o = 0.00009; E3o = 0.0009; Noio = 0.1; X0 = [E1o; E2o; E3o; Noio]; %call fsolve fu...

4 years ago | 0

Answered
Estimate for Residual variance function calculation
x = normrnd(10, 1, 1, 100); y = 1 + 2 .* x + normrnd(0, 1, 1, 100); n = 100; xBar = mean(x); yBar = mean(y); %slope sxy = ...

4 years ago | 0

Answered
How to solve "Rank deficient, rank = 7, tol = 6.169247e+09." in nlinfit
There must be something that you misunderstood in the article. The problem from above is a linear fitting problem for the vecto...

4 years ago | 0

| accepted

Answered
There are 500 different sizes of a bolt ranging around 0.5 mm. I want to separate the sizes that are above or below the tolerance. then add those results in a column vector
boltMeasurements = 0.5+0.005*randn(500,1); n = length(boltMeasurements) %number of values in array which is n=500 different ...

4 years ago | 1

| accepted

Answered
help on solving system of differential equations
Your code gives f = y and g = z with the z in the solution for g as a free parameter. It has nothing to do with your function z(...

4 years ago | 1

| accepted

Answered
Issue with finding the indices of the minimum element in a 3-Dimensional Array
A = rand(10,10,11); B = A(:); index = find(A==min(B)) B(index) [i j k] = ind2sub([10 10 11],index) A(i,j,k)

4 years ago | 0

| accepted

Answered
Solving overdetermined linear sytem for possible solutions
Choose RI as a binary integer vector (0 or 1) of length N. Constraint is sum(RI) = K and sum(RI.'*A) = B. Of course, this is on...

4 years ago | 0

Answered
I need to make a Gaussian fit, problem is i dont know how to type the parameters using lsqcurvefit
M = [ 24.6 1.518572825 24.7 1.5083088954 24.8 1.5210166178 24.9 1.4203323558 24...

4 years ago | 1

| accepted

Load more