Community Profile

Ameer Hamza

Hong Kong Polytechnic University

3,740 total contributions since 2016

3.1416

View all

Contributions in
View by

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

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

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

4 hours ago | 0

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

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

convert each character of an array to int
Easy peasy x = '10000111101010110101'; y = x - '0'

7 hours ago | 1

| accepted

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

how to plot one variable against three variables ?

8 hours ago | 0

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

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

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

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

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

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

Channel

My MW records

1 day ago

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

how to get simscape electrical?

1 day ago | 0

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

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

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

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

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

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

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

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

1 day ago | 0

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

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

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