Using For loop to determine if a number is prime
To determine if a number n is prime, you have to check every number up to and including sqrt(n) and see whether that number is ...

9 jours ago | 0

Finding optimal coefficients while fitting multiple data in matlab
If they all follow the same model, just concatenate the 3 data sets and fit them as a single set. If each data set has a differ...

9 jours ago | 0

Why does the the f vector in a linear equation always consist of negative values?
Well, I've never heard of simlp, but many solvers, such as linprog() will only solve minimization problems, so if you have an ob...

9 jours ago | 1

| accepted

Efficient matrix multiplication for large sparse matrices stored as sparse column vectors
Note that I have little flexibility in the way these matrices are stored, since other parts of my code rely heavily on this. Th...

10 jours ago | 1

| accepted

calling dependent properties from one class to another
You access it the same as you would a non-Dependent property, object.property

10 jours ago | 0

Finding a value, index which lies between 2 points in an array
i=discretize(value,X) j = i+1 X([i,j])

10 jours ago | 0

| accepted

LMI involving Kronceker Product
See KRON, https://www.mathworks.com/help/matlab/ref/kron.html

10 jours ago | 0

How to subtract the elements of an array
At which line does the error occur?The only thing I can think of is that you accidentally have a variable called "sum" previousl...

10 jours ago | 0

How to select only ADJECTIVES from a list of strings?
Do you have a list of adjectives to cross check against? And what if a word is both an adjective and a noun, like "orange"? If y...

10 jours ago | 0

Finding a value, index which lies between 2 points in an array
i = interp1(X,1:numel(X),value,'previous') j = i+1 X([i,j])

10 jours ago | 0

When I plot f towards time amplitude is increasing I don't know why. It should be constant. what's wrong?
I don't see why f should be constant, but nor is it monotonically increasing. Once I fix your initialization code, I see a sine-...

10 jours ago | 0

| accepted

Using coeffs to extract a matrix
The coefficient matrix I want to extract is the one that would produce precisely this polynomial if I evaluated the vector-matri...

11 jours ago | 1

Find the upper surface of a 3d object.
Perhaps you can obtain the facet normals like in this example, https://www.mathworks.com/help/matlab/ref/triangulation.facenorm...

11 jours ago | 0

common tangent of double-well function
This might give you an acceptable discrete approximation, but note my comment. p=polyfit([0,1,2,3,0.5, 2.5],[0 0 0 0 -1, -10],4...

11 jours ago | 0

| accepted

If the row values in multiple columns = 1, set another column's row value to 1, else set to 0
D=all( X{:,{'A','B','C'}} , 2); X=[X,array2table(D)]

12 jours ago | 1

| accepted

Mixed-integer Linear Programming with double sum constraints and 3D optimization variable
data = someFun2ImportData('data.csv'); len = length(data); % Pairwise distance matrix dist_matrix = squareform(pdist([data(:,...

12 jours ago | 0

| accepted

I got an error in my script using fsolve command
>> F(x0) ans = 1900 -1000 NaN NaN

12 jours ago | 0

How to interpolate midpoints in a curve
The code is working fine. You think there is only one peak in the interval 200<=t<=300, but if you zoom in, you will see that th...

12 jours ago | 1

| accepted

How to add rows in the middle of a matrix
newVector = vertcat( yourVector(1:j-1), sixrows(:), yourVector(j:end) )

12 jours ago | 1

| accepted

How can I change step tolerance, optimality measure, or optimaility/consraint tolerance for a non-linear optimization problem?
This example shows how you can pass an optimoptions object to the solver https://www.mathworks.com/help/optim/ug/optim.problemd...

12 jours ago | 0

What can be a reverse permutation formula of n*m matrix
This version is also quite fast - maybe even faster than my other, fully vectorized answer. n=length(A); %% Forward tic; B...

12 jours ago | 0

What can be a reverse permutation formula of n*m matrix
Assuming A and B are always square, n=length(A); E=speye(n); S=circshift(E,[1,0]); T=kron(S,E)+kron(E,S); T(1:n,1:n)=E;...

13 jours ago | 0

| accepted

Finding consecutive values in a vector
Here's a way to do it using group1s from the File Exchange https://www.mathworks.com/matlabcentral/fileexchange/78008-group1s ...

13 jours ago | 0

define nvars as a function handle in genetic algorithm
nvars cannot evolve throughout the optimization, but conceivably your fitness function could contain optimization sub-problems a...

13 jours ago | 0

I'm trying to get a vector from a loop without doing the linspace function
You must tell the code where in vector you want each value placed.

14 jours ago | 0

How to calculate limit in n-number of times?
I can't quite understand what your code is trying to do, but if you are trying to get the k-th derivative of a polynomial, given...

14 jours ago | 0

Setup an optimization problem using Bayesian Optimization
The functions you have been looking at (e.g. bayesopt) don't appear to be general model fitting solvers. They look like they are...

14 jours ago | 0

| accepted

How do I create a function script to check the positive definiteness of a a square matrix of any size?
Sadly, I do not believe I can use that. I am supposed to write code using for loops and the det() function. The code below ful...

14 jours ago | 0

Image Registration Issues - imregister() is making my moving image more misaligned
I got better results with a multimodal registration. Also, masking out the background junk is a good idea. load Masks %Use the ...

15 jours ago | 0

| accepted