Answered

How do I simulate a differential equation that has a squared derivative term in Simulink?

The block diagram seems correct. You can also use this block: https://www.mathworks.com/help/simulink/slref/mathfunction.html to...

How do I simulate a differential equation that has a squared derivative term in Simulink?

The block diagram seems correct. You can also use this block: https://www.mathworks.com/help/simulink/slref/mathfunction.html to...

1 hour ago | 0

Answered

How can I find if there is at least one particular element in the string?

You can convert it to a string and then find how many contains a single 1 x = [1111,1112,1121,1211,2111,2112,2121,2211,2122,211...

How can I find if there is at least one particular element in the string?

You can convert it to a string and then find how many contains a single 1 x = [1111,1112,1121,1211,2111,2112,2121,2211,2122,211...

3 hours ago | 0

Answered

Research randi, fix, round, ceil, floor functions. • Can you generate a random integer number without using randi?

All the answers can be found on following links https://www.mathworks.com/help/matlab/ref/randi.html https://www.mathworks.co...

Research randi, fix, round, ceil, floor functions. • Can you generate a random integer number without using randi?

All the answers can be found on following links https://www.mathworks.com/help/matlab/ref/randi.html https://www.mathworks.co...

4 hours ago | 0

Answered

How to get a plot?

You can use fplot() syms t v v = dsolve('D2v=-2*Dv-3*v+4*10*sin(5*pi*t)','v(0)=0','Dv(0)=0','t') fplot(v) Also, defining OD...

How to get a plot?

You can use fplot() syms t v v = dsolve('D2v=-2*Dv-3*v+4*10*sin(5*pi*t)','v(0)=0','Dv(0)=0','t') fplot(v) Also, defining OD...

6 hours ago | 0

| accepted

Answered

fixed time step for ODE45

If you are only concerned about output at fixed time-step, then you can pass tspan as a vector of time-values tspan= tcon:0.01:...

fixed time step for ODE45

If you are only concerned about output at fixed time-step, then you can pass tspan as a vector of time-values tspan= tcon:0.01:...

6 hours ago | 0

Answered

convert each character of an array to int

Easy peasy x = '10000111101010110101'; y = x - '0'

convert each character of an array to int

Easy peasy x = '10000111101010110101'; y = x - '0'

7 hours ago | 1

| accepted

Answered

compare elements of a 2x1 column vector

You can directly make the comparison using the cell array c{1} = [1;0]; c{2} = [2;3]; comp_result = c{1}(1) > c{2}(2);

compare elements of a 2x1 column vector

You can directly make the comparison using the cell array c{1} = [1;0]; c{2} = [2;3]; comp_result = c{1}(1) > c{2}(2);

7 hours ago | 0

Answered

how to plot one variable against three variables ?

For solving for unknown variables, read about solve(). For plotting 3 variables against 1 variable, read about following functi...

how to plot one variable against three variables ?

For solving for unknown variables, read about solve(). For plotting 3 variables against 1 variable, read about following functi...

8 hours ago | 0

Answered

How to set the length of axis in figures?

The lengths in cm are only relevant when you print the figure. If you just want to control the aspect ratio, then you can use pb...

How to set the length of axis in figures?

The lengths in cm are only relevant when you print the figure. If you just want to control the aspect ratio, then you can use pb...

9 hours ago | 0

Answered

array with vectors as elements

You need a cell array: https://www.mathworks.com/help/matlab/cell-arrays.html c = {} c{1} = [1; 0]; c{2} = [0; 1]; Access t...

array with vectors as elements

You need a cell array: https://www.mathworks.com/help/matlab/cell-arrays.html c = {} c{1} = [1; 0]; c{2} = [0; 1]; Access t...

9 hours ago | 0

| accepted

Answered

How to extract the correct phase of a sine wave from data

That is because you are doing a discrete Fourier transform. There can be a bit of spectral leakage to other frequency components...

How to extract the correct phase of a sine wave from data

That is because you are doing a discrete Fourier transform. There can be a bit of spectral leakage to other frequency components...

10 hours ago | 0

Answered

Random Number Generation for Continuously Decrementing Range

Try this lb = 0; % initial upper bound ub = 1; % initial lower bound n = 10; % number of random point in each interval x =...

Random Number Generation for Continuously Decrementing Range

Try this lb = 0; % initial upper bound ub = 1; % initial lower bound n = 10; % number of random point in each interval x =...

11 hours ago | 0

Answered

How to run an mlapp from a .m file

See run(): https://www.mathworks.com/help/matlab/ref/run.html run('powerSystemLineBusDiagram.mlapp')

How to run an mlapp from a .m file

See run(): https://www.mathworks.com/help/matlab/ref/run.html run('powerSystemLineBusDiagram.mlapp')

11 hours ago | 0

Answered

Error in plotting (blank graph): Vector Size

Check the following code. You don't need to use eta(i+1). v = linspace(0,35,36); v = v * 0.44704; N = length(v); eta = zeros...

Error in plotting (blank graph): Vector Size

Check the following code. You don't need to use eta(i+1). v = linspace(0,35,36); v = v * 0.44704; N = length(v); eta = zeros...

1 day ago | 0

Answered

Error with solve function

You also need to define other variables as symbolic syms I1 I2 I3 R_s X_s X_m V1 X_r R_r Z1 eqn1 = I1*(R_s + X_s) + I3*X_m == ...

Error with solve function

You also need to define other variables as symbolic syms I1 I2 I3 R_s X_s X_m V1 X_r R_r Z1 eqn1 = I1*(R_s + X_s) + I3*X_m == ...

1 day ago | 0

Answered

how to get simscape electrical?

Simscape Electrical is a toolbox for Simulink. You can buy for your current license by going to your existing page or you can re...

how to get simscape electrical?

Simscape Electrical is a toolbox for Simulink. You can buy for your current license by going to your existing page or you can re...

1 day ago | 0

Answered

Matrix input/output to a Matlab function block in simulink

An alternate way is to create a parameter input in the MATLAB function block and give it the same name as the base workspace var...

Matrix input/output to a Matlab function block in simulink

An alternate way is to create a parameter input in the MATLAB function block and give it the same name as the base workspace var...

1 day ago | 0

Answered

How to reduce precision of digit after decimal point? Matlab (R2020a)

If you are only concerned with displaying the results with two digits after the decimal, then you can use fprintf a = 334.65980...

How to reduce precision of digit after decimal point? Matlab (R2020a)

If you are only concerned with displaying the results with two digits after the decimal, then you can use fprintf a = 334.65980...

1 day ago | 0

| accepted

Answered

Sort Cell Structure according to specific row

Are you tying to do something like this C; % 2xn cell array [~, idx] = sort([C{1,:}]); C = C(:, idx);

Sort Cell Structure according to specific row

Are you tying to do something like this C; % 2xn cell array [~, idx] = sort([C{1,:}]); C = C(:, idx);

1 day ago | 0

| accepted

Answered

Finding Transfer Function from Step Response

Another approach can be something like this. Consider the transfer function of the system is and the transfer function of inp...

Finding Transfer Function from Step Response

Another approach can be something like this. Consider the transfer function of the system is and the transfer function of inp...

1 day ago | 0

Answered

Finding Transfer Function from Step Response

You can do it using the system identification app: https://www.mathworks.com/help/ident/ref/systemidentification-app.html. For t...

Finding Transfer Function from Step Response

You can do it using the system identification app: https://www.mathworks.com/help/ident/ref/systemidentification-app.html. For t...

1 day ago | 0

| accepted

Answered

How to solve 3 interconnected equations?

If you have symbolic toolbox, you can use solve() syms M S R Rv = rand(10, 1); eq1 = M == S*3; eq2 = S == R+M; sol = so...

How to solve 3 interconnected equations?

If you have symbolic toolbox, you can use solve() syms M S R Rv = rand(10, 1); eq1 = M == S*3; eq2 = S == R+M; sol = so...

1 day ago | 0

Answered

How to put a preview figure window in a main figure window

You can create a second smaller axes x=0.01*rand(100,1); ax1 = axes(); [~,edges] = histcounts(log10(x)); histogram(x,10.^edg...

How to put a preview figure window in a main figure window

You can create a second smaller axes x=0.01*rand(100,1); ax1 = axes(); [~,edges] = histcounts(log10(x)); histogram(x,10.^edg...

1 day ago | 0

| accepted

Answered

Reading the arranged file name

natsort() from FEX is exactly made for such cases: https://www.mathworks.com/matlabcentral/fileexchange/47434-natural-order-file...

Reading the arranged file name

natsort() from FEX is exactly made for such cases: https://www.mathworks.com/matlabcentral/fileexchange/47434-natural-order-file...

1 day ago | 0

Answered

solve linear equation system with partially unknown coefficient matrix

One approach is to find a least square solution using fmincon() x = rand(4, 1); y = rand(4, 1); A = @(a) [a(1) a(2) 0 a(3);...

solve linear equation system with partially unknown coefficient matrix

One approach is to find a least square solution using fmincon() x = rand(4, 1); y = rand(4, 1); A = @(a) [a(1) a(2) 0 a(3);...

1 day ago | 0

Answered

3input vs 1 output Interpolation Problem

You need to use scatteredInterpolant() data = readtable('Data.xlsx'); idx = find(isnan(data.X), 1); data(idx:end, :) = []; ...

3input vs 1 output Interpolation Problem

You need to use scatteredInterpolant() data = readtable('Data.xlsx'); idx = find(isnan(data.X), 1); data(idx:end, :) = []; ...

1 day ago | 0

| accepted

Answered

Undefined function or variable 'dumphex'.

dumphex is not a MATLAB's function. Some other similar functions are available on FEX: https://www.mathworks.com/matlabcentral/f...

Undefined function or variable 'dumphex'.

dumphex is not a MATLAB's function. Some other similar functions are available on FEX: https://www.mathworks.com/matlabcentral/f...

1 day ago | 0

Answered

How to write the codes for this?

If you want to find value of 'b' for each value of 't' then try this tv = [89;132;202;263;321;362;421;473;575;663]; syms b t ...

How to write the codes for this?

If you want to find value of 'b' for each value of 't' then try this tv = [89;132;202;263;321;362;421;473;575;663]; syms b t ...

1 day ago | 1

Answered

How to synchronize non timeseries data?

By synchronize, if you mean having the same x-values for both datasets, then use intep1(): https://www.mathworks.com/help/matlab...

How to synchronize non timeseries data?

By synchronize, if you mean having the same x-values for both datasets, then use intep1(): https://www.mathworks.com/help/matlab...

1 day ago | 0