Answered

How create a cell array

reshape( num2cell((1:24).'*ones(1,150)) ,[],1)

How create a cell array

reshape( num2cell((1:24).'*ones(1,150)) ,[],1)

9 dagar ago | 0

| accepted

Answered

How to assign array values to object.object.property at once using deal?

No, you would have to do it in 2 steps, [Variables.Value] = deal (Data(:)); [SimIn(:).Variables] = deal (Variables);

How to assign array values to object.object.property at once using deal?

No, you would have to do it in 2 steps, [Variables.Value] = deal (Data(:)); [SimIn(:).Variables] = deal (Variables);

9 dagar ago | 0

| accepted

Answered

Loop for square matrix

The FGETL command might be useful, https://www.mathworks.com/help/matlab/ref/fgetl.html?s_tid=srchtitle#br4x18h-6

Loop for square matrix

The FGETL command might be useful, https://www.mathworks.com/help/matlab/ref/fgetl.html?s_tid=srchtitle#br4x18h-6

10 dagar ago | 0

| accepted

Answered

Can't use mtimesx, "A C/C++ compiler has not been selected"

Run mex- -setup from the Matlab prompt, >> mex -setup and select one of the available compilers.

Can't use mtimesx, "A C/C++ compiler has not been selected"

Run mex- -setup from the Matlab prompt, >> mex -setup and select one of the available compilers.

10 dagar ago | 0

| accepted

Answered

how to find the position of the max componunt

Call max() with two output arguments and only input the columns you are interested in getting the max for, [maxvalue, maxlocati...

how to find the position of the max componunt

Call max() with two output arguments and only input the columns you are interested in getting the max for, [maxvalue, maxlocati...

10 dagar ago | 0

Answered

continuous representation (image generation) of discrete data set

You can use griddedInterpolant() if your x,y are gridded sample locations, or else scatteredInterpolant().

continuous representation (image generation) of discrete data set

You can use griddedInterpolant() if your x,y are gridded sample locations, or else scatteredInterpolant().

10 dagar ago | 0

Answered

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 ...

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 ...

10 dagar ago | 0

Answered

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...

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...

10 dagar ago | 0

Answered

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...

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...

10 dagar ago | 1

| accepted

Answered

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...

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...

12 dagar ago | 1

| accepted

Answered

calling dependent properties from one class to another

You access it the same as you would a non-Dependent property, object.property

calling dependent properties from one class to another

You access it the same as you would a non-Dependent property, object.property

12 dagar ago | 0

Answered

Finding a value, index which lies between 2 points in an array

i=discretize(value,X) j = i+1 X([i,j])

Finding a value, index which lies between 2 points in an array

i=discretize(value,X) j = i+1 X([i,j])

12 dagar ago | 0

| accepted

Answered

LMI involving Kronceker Product

See KRON, https://www.mathworks.com/help/matlab/ref/kron.html

LMI involving Kronceker Product

See KRON, https://www.mathworks.com/help/matlab/ref/kron.html

12 dagar ago | 0

Answered

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...

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...

12 dagar ago | 0

Answered

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...

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...

12 dagar ago | 0

Answered

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])

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])

12 dagar ago | 0

Answered

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-...

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-...

12 dagar ago | 0

| accepted

Answered

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...

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...

13 dagar ago | 1

Answered

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...

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...

13 dagar ago | 0

Answered

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...

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...

13 dagar ago | 0

| accepted

Answered

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)]

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)]

13 dagar ago | 1

| accepted

Answered

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(:,...

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(:,...

13 dagar ago | 0

| accepted

Answered

I got an error in my script using fsolve command

>> F(x0) ans = 1900 -1000 NaN NaN

I got an error in my script using fsolve command

>> F(x0) ans = 1900 -1000 NaN NaN

14 dagar ago | 0

Answered

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...

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...

14 dagar ago | 1

| accepted

Answered

How to add rows in the middle of a matrix

newVector = vertcat( yourVector(1:j-1), sixrows(:), yourVector(j:end) )

How to add rows in the middle of a matrix

newVector = vertcat( yourVector(1:j-1), sixrows(:), yourVector(j:end) )

14 dagar ago | 1

| accepted

Answered

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...

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...

14 dagar ago | 0

Answered

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...

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...

14 dagar ago | 0

Answered

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;...

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;...

15 dagar ago | 0

| accepted

Answered

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 ...

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 ...

15 dagar ago | 0

Answered

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...

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...

15 dagar ago | 0