Community Profile

Ameer Hamza

Hong Kong Polytechnic University

2,624 total contributions since 2016

View all

Contributions in
View by

Try this function x_2dot = fcn(u) x_2dot = 0; % initialize to tell simulink about its size J = 0.01; B = 0.1; K = 0.01; R ...

1 hour ago | 0

using fprintf to display multiple values
Change the line to fprintf(' The factorial of %.0f is %.0f\n\n',numlist(i),facn) %...

1 hour ago | 0

How use interp2
You can use interp2 like this sigma = 1:6; OMEGA = 1:10; T = rand(6, 10); interp2(sigma, OMEGA, T.', 4, 5) % (4,5) is a sa...

12 hours ago | 0

trying to plot the graph but getting dots pls help me
Try this B=1; LL=1; n=1:0.25:2; s=0.5:0.5:10; for i = 1:numel(n) for j = 1:numel(s) y(i,j)=1+(n(i)*(0.5513*...

12 hours ago | 0

| accepted

Writing variables in .csv file and saving it
If you have R2019a or later, you can save the data in a cell array and use writecell() C = {'abc', 1, 'def' 1; 'def', 2, 'rfg',...

13 hours ago | 0

imshow produces error when used in subplot
From your code, it is not clear how did you assign the 2nd element of vector h. However, I recommend initializing 'h' with 'gobj...

13 hours ago | 0

| accepted

Uninstalling old versions of MATLAB
Each version of MATLAB installs independent files. You can safely delete an older version. Note that if you have saved your own ...

14 hours ago | 0

In first code, 'j' varies from 1 to b for j=1:b In second code, 'j' varies from i to b for j = i:b

14 hours ago | 0

| accepted

Create a continous stepwise increase in Simulink
You can use the MATLAB function block and a clock to create this signal as shown in the image The code inside the MATLAB func...

14 hours ago | 0

| accepted

DIfferentiating repetitions in a repeated sequence
Try this x = [1 1 1 1 2 2 2 3 3 3 3 3]; y = splitapply(@(x) {1000*x(1) + (1:numel(x))}, x, x); y = [y{:}]; Result >> y y...

15 hours ago | 1

How to vary the number of fields in inputdlg dynamically?
Something like this n = inputdlg('Number of Zones'); n = str2double(n{1}); prompts = compose('Zone %d', 1:n); y = inputdlg...

15 hours ago | 0

| accepted

Estimating inputs from outputs in neural networks
You may try fsolve(). However, due to the complexity of a neural network, it is unlikely that it will be able to find a solution...

16 hours ago | 0

How can I find the Power spectral density of a filtered Noise?
This example show how to plot PSD using FFT: https://www.mathworks.com/help/signal/ug/power-spectral-density-estimates-using-fft...

16 hours ago | 0

explict (pointwise) function from numerical solution to implicit equation
Try interp1 to create an explicit relation for 'y' in term of 'x' using the datapoints from fimplicit f = @(x, y) y - x.^2; fp...

16 hours ago | 0

Try this set(handles.raiz,'String',num2str(r)); Convert the numeric value to character value.

16 hours ago | 0

Random numbers around y-values
Try this x = 1:100; y = log(x); noise = (2*rand(size(y))-1).*0.15.*y; y_noise = y + noise; plot(x, y, 'r', x, y_noise, 'b...

16 hours ago | 0

16 hours ago | 0

Phase portrait of a 2 dimensional system that converges to a unit circle
try this dx_dt = @(x,y) (1-(x.^2+y.^2)).*x-3.*y.*(x.^2+y.^2); dy_dt = @(x,y) (1-(x.^2+y.^2)).*y+3.*x.*(x.^2+y.^2); [x, y] =...

17 hours ago | 1

| accepted

How can we find the internal width of a alphabet?
Try this im = im2double(imread('alif.png')); im_gray = rgb2gray(im); im_bin = imbinarize(im_gray); [row, col] = find(~im_b...

17 hours ago | 0

| accepted

How to get a column from a text file based on some conditions
Try this data = fileread('test.txt'); data = textscan(data, 'Node %1s: %f'); labels = [data{1}{:}]-64; vals = data{2}; Ar...

17 hours ago | 0

error using "=" in solving equation
That syntax is incorrect in MATLAB. You need to use fsolve() to solve an equation numerically n=2.2; m=1.86; p=0.153; %p is d...

21 hours ago | 0

Try this num=[303 4848 0]; den=[1 16 164]; ea=tf(num,den); subplot(1,2,1) step(ea) [t, y] = ode45(@odeFun, [0 1], [303; ...

1 day ago | 0

| accepted

How to create a local function during the code run
Dynamically creating a function name is not a recommended coding practice. Following shows how to do such a thing more efficient...

1 day ago | 1

How to dramatically speed-up the function plot
I am not sure what is the purpose of using second code is instead of the first when both create the same plots, however, if you ...

1 day ago | 0

Multiple prompt/input with inputdlg according to a value
Something like this num_colors = 4; prompts = cell(1, num_colors*2); prompts(1:2:end) = compose('Enter min value for color %d...

1 day ago | 1

| accepted

How do I plot a X-Y graph in matlab with data using "to workspace" block
Something like this plot(out.xout{8}.Data, out.yout{8}.Data)

1 day ago | 0

| accepted

Export variable/signal
Use writematrix() in R2019a and later writematrix(M, 'filename.txt') % M is matrix name for older versions, you can use dlmwri...

1 day ago | 0

| accepted

Working with data in table
You can use data property to change data of a uitable object app.UITable.Data{2,3} = '1,2'; It will set 2nd row of 3rd column ...

1 day ago | 0

| accepted

Saving my .txt file as a .mat file to use it as data for my script.

1 day ago | 0

| accepted