Community Profile

# Ameer Hamza

### Hong Kong Polytechnic University

1,384 total contributions since 2016

View all

Contributions in
View by

Strange problem with tspan in ode45
This issue is not about accuracy. When you use tspan=[0 100], the t vector returned by ode45 is adaptively spaced. The differenc...

5 hours ago | 1

Extracting only few numeric columns from alphanumeric .out file.
try this data = fileread('DJI3fq3.txt'); loc_nl = find(data==newline); % getting locations of all newlines nl_double_nl = str...

6 hours ago | 0

try something like this figure plot([1,2],[1,2]) set(gca,'TickLabelInterpreter','latex') xticks(1:0.5:2) ax = gca; xtickfo...

7 hours ago | 1

| accepted

Can you help me with my problem ?
This will work in R2016b and later. x = 11:60; y = 0:10:490; M = x+y'; Earlier releases x = 11:60; y = 0:10:490; M = bsxf...

7 hours ago | 0

Array indices must be positive integers or logical values.
Change the line f2=@(t,cSrum) (c1*exp(lambda(b-t))*(flm/fpf)*cSrlm(i))-(c1*exp(lambda(b-t))*flm*cSrlm(i)*18)-(c1*exp(lambda(b-t...

7 hours ago | 0

Randomly choosing one of two options with specified probability
If you always want to keep fixed numbers of 1s and 2s, they try something like this N = 10; p2 = 0.4; out = ones(1,10); id...

8 hours ago | 0

Throw Error in TimerFcn
TimerFcn can either be a function handle or the name of a function. To display anything, you need to use a function. For example...

9 hours ago | 0

main question: how to make function vectorized
Vectorization means that the function should be able to accept arrays and apply an operation on all of its elements. In that sen...

9 hours ago | 0

how can i calculate the series using the first 10 terms of the sequence
try this term = 0; % initialize variable % loop 10 times for n = 0:9 % calculate term term(n+2) = term(n+1) + (1 / factoria...

10 hours ago | 0

How to fit data to another data
You can try something like this x % the normalized array y % the unnormalized array y_norm = normalize(y, 'range')*(max(x)-mi...

10 hours ago | 0

State space modeling of LTI
Such LTI system can be solved using lsim C=[3,4]; D=0.1; L=[0 1]; sys = ss(A,B,C,D); t = linspace(0,20,1000)'; x0 = [1;...

11 hours ago | 1

confronting cell with abelians (logic values)
[A{~B}] = deal('0');

11 hours ago | 0

I cannot integrate after the summation inside the FOR loop. I want to integrate with respect to x.
Although I believe that what you are trying to do, can be done in a much simpler way, it is easier to suggest a solution without...

11 hours ago | 0

Error while executing integral function
Change the line fun = @(r) F(r)*b*r; to fun = @(r) F(r)*b(r)*r; and replace A(ii) = a * integral(@(r) fun,0,1,"ArrayValued"...

12 hours ago | 0

| accepted

Comapre arrays of two cells and keep similar arrays
Try this load('A.mat') load('B.mat') A_lat_lon = cell2mat(cellfun(@(x) {[x.lon(1) x.lat(1)]}, A)'); B_lat_lon = cell2mat(c...

12 hours ago | 1

| accepted

How to turn 0 into blanks in a 2D array?
Try this A= [5, 4, 6, 7, 3; 1, 2, 3, 4, 5 ; 5, 6, 4, 2, 4; 4, 5, 3, 2, 1]; A(2:end-1,2:end-1) = 0; B = strrep(string(num2str(...

12 hours ago | 1

How to raise a decimal numbers as power of A??
If you want to do the element-wise exponential operation, the following will work on R2016b and onward versions B = A.^reshape(...

14 hours ago | 1

| accepted

generate random number from a function that serves as PDF ?
You can use the inverse transform sampling method: https://en.wikipedia.org/wiki/Inverse_transform_sampling to generate a random...

16 hours ago | 0

Engineering lab Vector length error
Change the lines Jaox = diff(Aaox); Jaoy = diff(Aaoy); Jaor = diff(Aa); to Jaox = gradient(Aaox); Jaoy = gradient(Aaoy); ...

17 hours ago | 0

Unexplained error using fitdist with Stable distro - help?
The error message shows that MATLAB defines a function named stablefit internally for its own use. The definition of stablefit f...

17 hours ago | 0

i need to solve 7 nonlinear equations with 7 unknowns and error is occurring while compiling the codes
It is a common practice to initialize arrays with zeros instead of nan. Correct two lines in your code G = 600:100:1200; x0 = ...

19 hours ago | 0

array exceeds maximum array size using dbscan function
pdist2 can indeed exhaust the memory. If the inputs are vectors of size m and n, then it returns a matrix of size m*n. If m and ...

19 hours ago | 0

Input function must return 'double' or 'single' values. Found 'sym'.
Correct syntax is to use 'syms', not 'sym'. Also you should use matlabFunction to convert symbolic equation to numeric clc cle...

19 hours ago | 0

| accepted

What is the complexity of solving LMI in Matlab?
MATLAB documentation usually mentions the Algorithm used to implement the Algorithm. For example, check this LMI solver: https:/...

19 hours ago | 0

change the simulation stop time from a block
You can stop the simulation at any using stop block: https://www.mathworks.com/help/simulink/slref/stopsimulation.html. You can ...

1 day ago | 0

Boundary value problem with bvp4c
There were issues in your ODE function and the BC function. Replace them with these defintions. function res = bc(ya,yb) res =...

1 day ago | 1

| accepted

Filling a region between parametric curves?
The actual issue is the order of the point. The patch function fails because the points are not distributed as a closed-loop. Th...

1 day ago | 1

| accepted

First, since w is a vector, you should be using element-wise multiplication (.*). Second, you cannot use diff() on a numerical v...

1 day ago | 2

| accepted

Unable to perform assignment because the left and right sides have a different number of elements
In your code, you have the line Ez(x0) = Ez(x0) + pulse x0 = 15, so Ez(x0) denotes the 15th element of Ex vector, i.e, a scala...

1 day ago | 0