Answered

How to randomly select 2 rows

You can use the output of randperm as index M = rand(10, 5); % random matrix rows = randperm(size(M,1), 2) M_new = M(rows, :)...

How to randomly select 2 rows

You can use the output of randperm as index M = rand(10, 5); % random matrix rows = randperm(size(M,1), 2) M_new = M(rows, :)...

1 hour ago | 1

Answered

how to export value of a Variable vector to dedicated coulmn in UITable app designer

The correct solution depends on how you initialized the Data property of UITable and how did you define T. But my guess is that ...

how to export value of a Variable vector to dedicated coulmn in UITable app designer

The correct solution depends on how you initialized the Data property of UITable and how did you define T. But my guess is that ...

3 hours ago | 0

Answered

Division of two matrices

mrdivide: http://xl48.cn/help/fixedpoint/ref/embedded.fi.mrdivide.html B = C/A

Division of two matrices

mrdivide: http://xl48.cn/help/fixedpoint/ref/embedded.fi.mrdivide.html B = C/A

4 hours ago | 0

Answered

calculation of eigenvalues and eigenvectors

See eig(): http://xl48.cn/help/matlab/ref/eig.html. Normal eigenvalue assumes to be one along the diagonal. You will ...

calculation of eigenvalues and eigenvectors

See eig(): http://xl48.cn/help/matlab/ref/eig.html. Normal eigenvalue assumes to be one along the diagonal. You will ...

5 hours ago | 0

Answered

how to plot given plane in matlab (It will be 3d)

A simple solution is to use fimplicit3 f = @(x, y, z) 4.7243+1.1351*x + 3.1351*z - y; fimplicit3(f); An alternative solution ...

how to plot given plane in matlab (It will be 3d)

A simple solution is to use fimplicit3 f = @(x, y, z) 4.7243+1.1351*x + 3.1351*z - y; fimplicit3(f); An alternative solution ...

6 hours ago | 0

| accepted

Answered

Extract non-zero cells from array (of non-uniform vectors)

isempty() with cellfun() will work datas=cell(20,5); datas{15,2}=[1 0 1 0 1]; datas{7,3}=[1 0 1 ]; datas{5,5}=[1 0 1 0 1 1 1...

Extract non-zero cells from array (of non-uniform vectors)

isempty() with cellfun() will work datas=cell(20,5); datas{15,2}=[1 0 1 0 1]; datas{7,3}=[1 0 1 ]; datas{5,5}=[1 0 1 0 1 1 1...

7 hours ago | 1

| accepted

Answered

How to include text in a running figure

Something like this t = linspace(0, 2*pi); y = sin(t); ax = axes(); ax.XLim = [0 2*pi]; ax.YLim = [-1.5 1.5]; hold(ax); ...

How to include text in a running figure

Something like this t = linspace(0, 2*pi); y = sin(t); ax = axes(); ax.XLim = [0 2*pi]; ax.YLim = [-1.5 1.5]; hold(ax); ...

10 hours ago | 0

Answered

How can i take ds/dx and ds/dy of a function numerically

The numerical gradient can not be exactly equal to the analytical gradient, except in very simple cases. For any nonlinear funct...

How can i take ds/dx and ds/dy of a function numerically

The numerical gradient can not be exactly equal to the analytical gradient, except in very simple cases. For any nonlinear funct...

22 hours ago | 0

| accepted

Answered

How to find values in structure?

Like this MyRegionFirstParameter(1).data(x) = S(1).data(x);

How to find values in structure?

Like this MyRegionFirstParameter(1).data(x) = S(1).data(x);

22 hours ago | 1

| accepted

Answered

How can I form a vector operating with another?

n = 0:100; y = (2.^n)./(2*n); You need to use element-wise operators: http://xl48.cn/help/matlab/matlab_prog/array-...

How can I form a vector operating with another?

n = 0:100; y = (2.^n)./(2*n); You need to use element-wise operators: http://xl48.cn/help/matlab/matlab_prog/array-...

22 hours ago | 0

| accepted

Answered

Generate random numbers matrix with different probabilities

This is one way candidates = [-5:0 -5:0 1:23]; % twice as many candidates from -5 to 0 idx = randi(numel(candidates), 15, 20);...

Generate random numbers matrix with different probabilities

This is one way candidates = [-5:0 -5:0 1:23]; % twice as many candidates from -5 to 0 idx = randi(numel(candidates), 15, 20);...

22 hours ago | 0

Answered

How Can I Save a Struct Array to a Text File?

You can directly create a matrix M = cell2mat(struct2cell(s(:)).') writematrix(M, 'filename.txt')

How Can I Save a Struct Array to a Text File?

You can directly create a matrix M = cell2mat(struct2cell(s(:)).') writematrix(M, 'filename.txt')

22 hours ago | 0

Answered

how to code simple pendulum motion using ode45

The equation of simple pendulum is , which can be converted to two first order ODEs and then using ode45 like this theta_ic ...

how to code simple pendulum motion using ode45

The equation of simple pendulum is , which can be converted to two first order ODEs and then using ode45 like this theta_ic ...

22 hours ago | 0

| accepted

Answered

Sum matrix from n=1 to n

Try this m = [2 1 2 3]; out = zeros(size(EGSE_bat,1), 1, size(EGSE_bat,3)); for i = 1:size(EGSE_bat,3) out(:,:,i) = su...

Sum matrix from n=1 to n

Try this m = [2 1 2 3]; out = zeros(size(EGSE_bat,1), 1, size(EGSE_bat,3)); for i = 1:size(EGSE_bat,3) out(:,:,i) = su...

23 hours ago | 1

| accepted

Answered

Dimensions of arrays being concatenated are not consistent.

The cell array is made for such cases: http://xl48.cn/help/matlab/cell-arrays.html. It works almost the same, except...

Dimensions of arrays being concatenated are not consistent.

The cell array is made for such cases: http://xl48.cn/help/matlab/cell-arrays.html. It works almost the same, except...

1 day ago | 0

Answered

Work with Symbolic Math Toolbox with units and export data to Simulink´s models parameters

As the error message also mentions, you need to use separateUnits before converting it to double L_LV_dato = double(separateUni...

Work with Symbolic Math Toolbox with units and export data to Simulink´s models parameters

As the error message also mentions, you need to use separateUnits before converting it to double L_LV_dato = double(separateUni...

1 day ago | 0

| accepted

Answered

How to display the filename correctly?

You are using the command format of export_fig. MATLAB does not understand fig_name is used to refer a variable and just conside...

How to display the filename correctly?

You are using the command format of export_fig. MATLAB does not understand fig_name is used to refer a variable and just conside...

1 day ago | 0

| accepted

Answered

Function to chop a decimal to a variable number of digits

MATLAB does not recognize what does 'x' means inside fprintf() function call. Try the following code chop(3,4.333352312) func...

Function to chop a decimal to a variable number of digits

MATLAB does not recognize what does 'x' means inside fprintf() function call. Try the following code chop(3,4.333352312) func...

2 days ago | 0

Answered

Format coefficients of the derivative of a function

Convert everthing to symbolic to prevent the loss of precision syms x e = exp(sym(1)); f = x * e^x^2; format short df = di...

Format coefficients of the derivative of a function

Convert everthing to symbolic to prevent the loss of precision syms x e = exp(sym(1)); f = x * e^x^2; format short df = di...

2 days ago | 0

| accepted

Answered

How to read multiple .wav files and plot them as separate signals?

Check this code files = dir('file*'); f = figure(); destination_folder = ''; % put location of destimation folder for i = ...

How to read multiple .wav files and plot them as separate signals?

Check this code files = dir('file*'); f = figure(); destination_folder = ''; % put location of destimation folder for i = ...

2 days ago | 0

Answered

String input saves as character.

The correct function name is str2double(), not str2dbl().http://xl48.cn/help/releases/R2020b/matlab/ref/str2double.ht...

String input saves as character.

The correct function name is str2double(), not str2dbl().http://xl48.cn/help/releases/R2020b/matlab/ref/str2double.ht...

2 days ago | 0

| accepted

Answered

How do I plot the intersections of two functions???

See this FEX package: http://xl48.cn/matlabcentral/fileexchange/22441-curve-intersections

How do I plot the intersections of two functions???

See this FEX package: http://xl48.cn/matlabcentral/fileexchange/22441-curve-intersections

2 days ago | 0

Answered

Loading variables & using 'for' loop for comman polyeig()

It is not a good idea to name variable like K1, K2, K3, ... It makes code complicated: http://xl48.cn/matlabcentral/a...

Loading variables & using 'for' loop for comman polyeig()

It is not a good idea to name variable like K1, K2, K3, ... It makes code complicated: http://xl48.cn/matlabcentral/a...

2 days ago | 0

| accepted

Answered

Extracting the mathematical equation from the Neural Network

Why use a neural network if you want a polynomial fit. Simply use polyfit(): http://xl48.cn/help/matlab/ref/polyfit.h...

Extracting the mathematical equation from the Neural Network

Why use a neural network if you want a polynomial fit. Simply use polyfit(): http://xl48.cn/help/matlab/ref/polyfit.h...

2 days ago | 0

Answered

Normalize using first element of vector

A = [10 20 15 12]; A_new = A/A(1)*100; Using normalize() normalize(A, 'scale', 'first')*100

Normalize using first element of vector

A = [10 20 15 12]; A_new = A/A(1)*100; Using normalize() normalize(A, 'scale', 'first')*100

2 days ago | 0

| accepted

Answered

Accessing Table entries in MATLAB

There are several ways to access data in MATLAB table: http://xl48.cn/help/matlab/matlab_prog/access-data-in-a-table....

Accessing Table entries in MATLAB

There are several ways to access data in MATLAB table: http://xl48.cn/help/matlab/matlab_prog/access-data-in-a-table....

2 days ago | 0

Answered

How to convert from FORTRAN TO MATLAB

I don't think you can automatically convert your FORTRAN code to MATLAB; however, you can compile it as mex file and use it in M...

How to convert from FORTRAN TO MATLAB

I don't think you can automatically convert your FORTRAN code to MATLAB; however, you can compile it as mex file and use it in M...

2 days ago | 0

Answered

Pair the index of aray's same values

Try this b=[1 2 2 1 3 4 1 3 4 3 5 6]; [r, c] = find(squareform(pdist(b.'))==0); pairs = sortrows([r(c > r) c(c > r)]); Res...

Pair the index of aray's same values

Try this b=[1 2 2 1 3 4 1 3 4 3 5 6]; [r, c] = find(squareform(pdist(b.'))==0); pairs = sortrows([r(c > r) c(c > r)]); Res...

2 days ago | 2

| accepted

Answered

Use subscript and superscript in legend

plot(1:10); legend('$\overline{H}_{debris}^{front}$', ... 'Interpreter', 'latex', ... 'FontSize', 16, ... 'loc...

Use subscript and superscript in legend

plot(1:10); legend('$\overline{H}_{debris}^{front}$', ... 'Interpreter', 'latex', ... 'FontSize', 16, ... 'loc...

2 days ago | 0

Answered

Numerical Integration in Matlab

If you have symbolic toolbox syms x y = ((x.^4 .* exp(x))) ./ ((exp(x) - 1) .* (exp(x) - 1) ); I = int(y, x, 0, inf) Result ...

Numerical Integration in Matlab

If you have symbolic toolbox syms x y = ((x.^4 .* exp(x))) ./ ((exp(x) - 1) .* (exp(x) - 1) ); I = int(y, x, 0, inf) Result ...

2 days ago | 0

| accepted