Community Profile

# Ameer Hamza

### Hong Kong Polytechnic University

4,457 total contributions since 2016

3.1416

View all

Contributions in
View by

Converting cell array to matrix
Use vertcat() coord = vertcat(centroid1{:}) following should also work coord = cell2mat(centroid1.')

34 minutes ago | 0

| accepted

How to make the y axis 'counts' and x axis the variable on Histograms
One option is to just rotate the view x = rand(1000,1); histogram(x) view(90, 90) Combining histcounts() with barh() is anot...

42 minutes ago | 0

Infinite Recursion in own Levenberg-Marquardt Code
Inside the function korrektur, you are again calling korrektur with the same value of input parameter [s,mu]=korrektur(f,DF,x,...

1 hour ago | 1

imwrite error for saving contents of a cell array in a for loop - "colourmap should have 3 columns"?
Why are you getting the indexed image in frame2im(). Getting an RGB image will make things easier. Change the line to figureIm ...

2 hours ago | 1

| accepted

How to Select Specific Time Intervals Over a series of time steps
Is the data loaded in MATLAB? If yes, you can do something like this dts; % datetime vector; Transp_val; % Transpiration value...

2 hours ago | 0

Simulink: Excite System for couple seconds but longer simulation time
There can be several ways, but the easiest might be to use a MATLAB function block: https://www.mathworks.com/help/simulink/ug/c...

2 hours ago | 0

How to plot scatter graph with colourmap functon
Try this x = myVal(:,1); y = myVal(:,2); z = myVal(:,3); cmap = jet(256); %state colourmaop min_val = min(z); max_val = ...

2 hours ago | 0

| accepted

multiple function_handle in one function
Instead of defining three function handles, you can defined one vector-valued functions df = @(a) [2.*((sqrt((x1-a(1)).^2 + (y1...

2 hours ago | 1

Use Matlab online for machine learning
MATLAB online itself does not have enough power to do something serious. For example, it does not have a GPU device. You can run...

3 hours ago | 0

How to Write y(0)=1?
If you just want to display it, then you can use following code syms J(theta) J(theta)=1 This requires the Symbolic toolbox.

4 hours ago | 0

How sampling 3d scattered points
One option is to use interp1() X = rand(108, 3); t = linspace(0,1,size(X,1)); t_new = linspace(0,1,32); X_new = interp1(t,...

4 hours ago | 1

How to find the Fourier transform X(ω)
fourier() works with symbolic inputs syms t x(t) = (t*exp(-3*t)*sin(8*t))*heaviside(t); fourier(x)

4 hours ago | 0

| accepted

How to use isosurface in app designer?
isosurface() surface is quite an old function and does not support these features. According to the documentation, it will just ...

4 hours ago | 0

4th order differential equation
If you have symbolic toolbox, then try this syms v(z) P EI eq = EI*diff(v,4) == -P*z v = dsolve(eq) Result from live edito...

4 hours ago | 0

Read two lines from a file and repeat for next lines
It is more efficient to read everything in a single call. I/O operations on disk can be a bottleneck, so that should be reduced ...

6 hours ago | 0

| accepted

How to create a variable named from string
Although possible, it is a terrible (cannot emphasize enough) coding practice to create variable names dynamically: https://www....

6 hours ago | 0

| accepted

Pseudo random sequence matrix from an image
As the documentation specifies, the Y matrix has values in the range [16 235]/255 for the floating-point datatype. You can do so...

6 hours ago | 0

Grouping of sub arrays
Are you looking for something like this x=[1 1 2 3 3 1 0 4 4 4 1 1 1 1 5 5 0 1 3 3 3 3 1 4 4 4 0 0 1 1 5 6]; Groups = bwlabe...

6 hours ago | 0

How to create a graph time vs value n
I think it might be better if you move the tic ... toc lines outside the function. For example, remove these lines and then run ...

7 hours ago | 0

How to separate negative and positive terms in to two different expressions
Try this syms a b c d f g F = a - b*d + g*c - a*c + d*g; parts = children(F); parts = [parts{:}]; assume(symvar(parts)>0)...

7 hours ago | 1

| accepted

Formatting Matlab's output to Command Window
The format short only applies to native numeric datatypes, e.g., double. Generally, it is preferable to display symbolic calcula...

8 hours ago | 1

| accepted

MATLAB function cross can be applied to symbolic object but Documentation does not explain?
It works fine in R2020b, are you using an older release? syms x y z vec1 = [x y z]; vec2 = [x y z]; x = cross(vec1, vec2); ...

8 hours ago | 0

how to add non uniform Noise
What about multiplying the noise matrix with another function. For example M = randn(13); [~,~,Z] = peaks(13); % peaks is just...

10 hours ago | 0

Plotting 16 plots in one figure using handle graphics
Try this n = 4; dim = 0.8/n-0.05; % considering that the axes will go from 0.1 to 0.9 in figure coordinates ...

11 hours ago | 0

Array of Numbers with error
What type of noise you you want to add? Following shows an example with normally distributed noise. acc79_18; % data from 1979 ...

11 hours ago | 0

Why is my functions not plotting a line?
Change the lines in your code like this Wcd=(s.*Wab.*(s+sin(theta)))./(1+s.^2+2.*s.*sin(theta)); %^...

21 hours ago | 2

| accepted

How to use two colormaps in one imagesc plot?
You can create a new colormap based on the proportion of the individual colormap imagesc(M); colorbar(); caxis([-0.8 1]); cm...

22 hours ago | 1

| accepted

Read and display RGB png/jpg image
You png file is actually an indexed image with a colormap. You can see it in color using following statements [img, map] = imre...

22 hours ago | 0

| accepted

Alternatives for passing variables efficiently to anonymous function
Don't bring 'f' as string. Define it as function handle. For example, define f like this f = @(x, LDamperFL, LDamperFR, xSteerR...

22 hours ago | 0

| accepted