Answered

append sections of column by n rows to subsequent column

You can use reshape() v; % 1032x1 vector M = reshape(v, 43, [])

append sections of column by n rows to subsequent column

You can use reshape() v; % 1032x1 vector M = reshape(v, 43, [])

10 days ago | 0

Answered

Please Help Optimization using PSO

Check the code of this FEX package: https://www.mathworks.com/matlabcentral/fileexchange/75101-non-linear-equality-and-inequalit...

Please Help Optimization using PSO

Check the code of this FEX package: https://www.mathworks.com/matlabcentral/fileexchange/75101-non-linear-equality-and-inequalit...

11 days ago | 0

Answered

How can I find distances between 100 points such that I have a set of distances of each point from rest of the points.

Just use pdist() function X = [..]; % create 100x3 matrix dists = pdist(X)

How can I find distances between 100 points such that I have a set of distances of each point from rest of the points.

Just use pdist() function X = [..]; % create 100x3 matrix dists = pdist(X)

13 days ago | 1

Answered

Binary value convert.

Read about logical indexing A = [0 1 0 1;1 0 0 1; 0 0 0 1; 1 0 0 1]; A(A==0) = -1;

Binary value convert.

Read about logical indexing A = [0 1 0 1;1 0 0 1; 0 0 0 1; 1 0 0 1]; A(A==0) = -1;

13 days ago | 0

| accepted

Answered

matrix arithmetic numbers short way

Yes, quite easily. A = 1:30; Read about colon operator: https://www.mathworks.com/help/matlab/ref/colon.html

matrix arithmetic numbers short way

Yes, quite easily. A = 1:30; Read about colon operator: https://www.mathworks.com/help/matlab/ref/colon.html

14 days ago | 0

Answered

Change the sign of column of imported file in matlab.

Something like this M_new = M.*[-1 1]; % change sign of 1st column M_new = M.*[1 -1]; % change sign of 2nd column or M_new =...

Change the sign of column of imported file in matlab.

Something like this M_new = M.*[-1 1]; % change sign of 1st column M_new = M.*[1 -1]; % change sign of 2nd column or M_new =...

14 days ago | 0

Answered

obtaining large numbers while using syms

Specify the number of digits in vpa() to vpa(x, 4)

obtaining large numbers while using syms

Specify the number of digits in vpa() to vpa(x, 4)

15 days ago | 0

Answered

Consider preallocating for speed

It is not an error message; it is just a warning. Pre-allocation helps make the code faster. Read my answer here to get a genera...

Consider preallocating for speed

It is not an error message; it is just a warning. Pre-allocation helps make the code faster. Read my answer here to get a genera...

15 days ago | 0

| accepted

Answered

How can increase a binary image in size by padding ?

See padarray(): https://www.mathworks.com/help/images/ref/padarray.html For example im = imread('https://www.mathworks.com/ma...

How can increase a binary image in size by padding ?

See padarray(): https://www.mathworks.com/help/images/ref/padarray.html For example im = imread('https://www.mathworks.com/ma...

15 days ago | 0

| accepted

Answered

finding all roots of a trignometric equation

range of tan(x) is (-inf inf), so this equation has an infinite number of solutions. Also, the solutions to this equation cannot...

finding all roots of a trignometric equation

range of tan(x) is (-inf inf), so this equation has an infinite number of solutions. Also, the solutions to this equation cannot...

16 days ago | 0

Answered

Add elements to a matrix

Use repelem() A = [1 2 3; 4 5 6; 7 8 9] B = repelem(A, 1, 2) Note: In MATLAB [ ] are used to create arrays.

Add elements to a matrix

Use repelem() A = [1 2 3; 4 5 6; 7 8 9] B = repelem(A, 1, 2) Note: In MATLAB [ ] are used to create arrays.

16 days ago | 1

| accepted

Answered

Logical Indexing Within a Symbolic Array

Try this syms w1 w2 w3 w4 w5 w6 w7 w8 w9 w10 A = [0 0 0 w7 0 0; 0 0 0 0 w9 0; 0 w3 0 0 0 0; 0 0 w5 0 0 0; ...

Logical Indexing Within a Symbolic Array

Try this syms w1 w2 w3 w4 w5 w6 w7 w8 w9 w10 A = [0 0 0 w7 0 0; 0 0 0 0 w9 0; 0 w3 0 0 0 0; 0 0 w5 0 0 0; ...

16 days ago | 0

| accepted

Answered

How do I replace elements in a vector with other vectors?

Don't create variable name dynamically like rectColor1, rectColor2, .. It always makes code more difficult. Following shows how ...

How do I replace elements in a vector with other vectors?

Don't create variable name dynamically like rectColor1, rectColor2, .. It always makes code more difficult. Following shows how ...

16 days ago | 0

| accepted

Answered

Read STL FILE on MATLAB

No, this is not how a function is called in MATLAB. Read here: https://www.mathworks.com/help/matlab/matlab_prog/create-function...

Read STL FILE on MATLAB

No, this is not how a function is called in MATLAB. Read here: https://www.mathworks.com/help/matlab/matlab_prog/create-function...

16 days ago | 0

| accepted

Answered

Difference between datetime values in minutes

Try this col = minutes([all_combined_short{:,1}].'-all_combined_short{1,1})+1; all_combined_short = [num2cell(col), all_combin...

Difference between datetime values in minutes

Try this col = minutes([all_combined_short{:,1}].'-all_combined_short{1,1})+1; all_combined_short = [num2cell(col), all_combin...

16 days ago | 2

| accepted

Answered

Placing data in a matrix

Directly use reshape() B = reshape(A, [36 353]).'

Placing data in a matrix

Directly use reshape() B = reshape(A, [36 353]).'

16 days ago | 0

| accepted

Answered

How to generating surface without plotting?

Since it is a graphical object, you cannot create it without plotting somewhere. However, you can make the figure invisible so t...

How to generating surface without plotting?

Since it is a graphical object, you cannot create it without plotting somewhere. However, you can make the figure invisible so t...

16 days ago | 0

| accepted

Answered

Calculate mean value from different matrices

How are 5 matrices available? Is it a cell array? Try something like this C = {M1, M2, M3, M4, M5}; M = cat(3, C{:}); M_mean ...

Calculate mean value from different matrices

How are 5 matrices available? Is it a cell array? Try something like this C = {M1, M2, M3, M4, M5}; M = cat(3, C{:}); M_mean ...

16 days ago | 0

| accepted

Answered

Create function such that for each element of the vector it applies different function

Try something like this a = 1; b = 1; x = [2; 4]; f1 = @(x) a*x(1) + 1; f2 = @(x) b*x(2) - 1; F = @(x) [f1(x); f2(x)];...

Create function such that for each element of the vector it applies different function

Try something like this a = 1; b = 1; x = [2; 4]; f1 = @(x) a*x(1) + 1; f2 = @(x) b*x(2) - 1; F = @(x) [f1(x); f2(x)];...

16 days ago | 0

| accepted

Answered

call function for each combination of rows in A and columns in B

Try this Xtrain = [1 2; 3 4; 5 6]; Xtest = [7 8 ; 9 10]; kernel = @(x1,x2) norm(x1 - x2); m = size(Xtrain, 1); n = size(X...

call function for each combination of rows in A and columns in B

Try this Xtrain = [1 2; 3 4; 5 6]; Xtest = [7 8 ; 9 10]; kernel = @(x1,x2) norm(x1 - x2); m = size(Xtrain, 1); n = size(X...

16 days ago | 1

| accepted

Answered

caxis equivalent for slice plot

caxis() also works for slice(). See the difference between two figures [X,Y,Z] = meshgrid(-2:.2:2); V = X.*exp(-X.^2-Y.^2-Z.^2...

caxis equivalent for slice plot

caxis() also works for slice(). See the difference between two figures [X,Y,Z] = meshgrid(-2:.2:2); V = X.*exp(-X.^2-Y.^2-Z.^2...

16 days ago | 0

| accepted

Answered

How do i make this code as simple as possible? :(

First, naming variables like final_1, final_2, ... is a bad coding practise: https://www.mathworks.com/matlabcentral/answers/304...

How do i make this code as simple as possible? :(

First, naming variables like final_1, final_2, ... is a bad coding practise: https://www.mathworks.com/matlabcentral/answers/304...

16 days ago | 0

| accepted

Answered

Taylor expansion calculation of exp(x^2)

The formula for taylor series is correct. Just increase the number of terms. x = -3.0:0.1:3.0; N = 12; Taylor_p2 = 0; for n ...

Taylor expansion calculation of exp(x^2)

The formula for taylor series is correct. Just increase the number of terms. x = -3.0:0.1:3.0; N = 12; Taylor_p2 = 0; for n ...

16 days ago | 1

| accepted

Answered

Outputing a correspond element of another variable

Try this A = ["Bayo" "Tun" "s"]; B = [21, 45, 11]; [~, idx] = max(B); output = A(idx); Result >> output output = ...

Outputing a correspond element of another variable

Try this A = ["Bayo" "Tun" "s"]; B = [21, 45, 11]; [~, idx] = max(B); output = A(idx); Result >> output output = ...

16 days ago | 1

| accepted

Answered

How can I interpolate a datetime data series to have an interval of 1 minute in MATLAB?

Try something like this T = readtable('sample.xlsx'); [grps, unique_mmsi] = findgroups(T.mmsi); tts = splitapply(@(la,lo,da...

How can I interpolate a datetime data series to have an interval of 1 minute in MATLAB?

Try something like this T = readtable('sample.xlsx'); [grps, unique_mmsi] = findgroups(T.mmsi); tts = splitapply(@(la,lo,da...

16 days ago | 1

| accepted

Answered

separet value in one colone to many colone

Try this mtx= [1 101; 2 011; 3 111; 4 110; 5 110]; cols = reshape(sprintf('%03d', mtx(:,2)), 3...

separet value in one colone to many colone

Try this mtx= [1 101; 2 011; 3 111; 4 110; 5 110]; cols = reshape(sprintf('%03d', mtx(:,2)), 3...

16 days ago | 1

Answered

How to perform high-precision fitting of points on unknown trajectories? And calculate the fitting coefficient.

If you don't have the equation, then use a non-parametric curve fitting: https://www.mathworks.com/help/curvefit/nonparametric-f...

How to perform high-precision fitting of points on unknown trajectories? And calculate the fitting coefficient.

If you don't have the equation, then use a non-parametric curve fitting: https://www.mathworks.com/help/curvefit/nonparametric-f...

16 days ago | 0

| accepted

Answered

How can I solve this complex 4 equation with 4 unknowns variables

You can specify 'MaxDegree' as input to solve() syms K1 K2 K3 K4 equ1 = K2+K4-36 equ2 = K2*K4+K3+K1-486 equ3 = K2+2*K2*K3+2*...

How can I solve this complex 4 equation with 4 unknowns variables

You can specify 'MaxDegree' as input to solve() syms K1 K2 K3 K4 equ1 = K2+K4-36 equ2 = K2*K4+K3+K1-486 equ3 = K2+2*K2*K3+2*...

16 days ago | 0

Answered

Do I need to uninstall another version of MATLAB before installing an new version with different products?

MATLAB installations are independent of each other. You can delete the previous installation directory directly before installin...

Do I need to uninstall another version of MATLAB before installing an new version with different products?

MATLAB installations are independent of each other. You can delete the previous installation directory directly before installin...

17 days ago | 0

| accepted

Answered

Contour plot of XYZ data

Try this x = hfm(:,1); y = hfm(:,2); z = hfm(:,3); xg = linspace(min(x),max(x)); yg = linspace(min(y),max(y)); [Xg, Yg] ...

Contour plot of XYZ data

Try this x = hfm(:,1); y = hfm(:,2); z = hfm(:,3); xg = linspace(min(x),max(x)); yg = linspace(min(y),max(y)); [Xg, Yg] ...

17 days ago | 0