Community Profile

photo

Ameer Hamza


Last seen: Today

Hong Kong Polytechnic University

3.064 total contributions since 2016

3.1416

Contact

Ameer Hamza's Badges

  • MATLAB Central Treasure Hunt Finisher
  • Scavenger Finisher
  • 6 Month Streak
  • Ace
  • Thankful Level 2
  • CUP Challenge Master
  • Promoter
  • Commenter
  • Explorer
  • Personal Best Downloads Level 2
  • Editor's Pick
  • First Review
  • 5-Star Galaxy Level 1
  • First Submission
  • Knowledgeable Level 4

View all

Contributions in
View by

Answered
Progress Bar and for loop
See this example f = waitbar(0, 'Starting'); n = 100; for i= 1:n % write your code here waitbar(i/n, f, sprintf('...

etwa 10 Stunden ago | 0

| accepted

Answered
How do I add color to this line of code without repeating the time variable everytime?
Use plot handles to set the color t = 1:10; x1 = rand(size(t)); x2 = rand(size(t)); p = plot(t, [x1; x2]); p(1).color = '...

etwa 10 Stunden ago | 0

| accepted

Answered
Creating random integer row array each element different upper limit and sum of elements add up to a number
See this excellent FEX package by John: https://www.mathworks.com/matlabcentral/fileexchange/49795-randfixedlinearcombination. H...

etwa 10 Stunden ago | 0

Answered
Transposing 5x5x5 matrix
You need to specify the order of the dimensions after transpose. It should be something like this permute(r, [2, 3, 1]) It mea...

etwa 11 Stunden ago | 0

Answered
Defining matlab logspace for semilogx plot
x = logspace(log10(400e-9), log10(700e-9))

etwa 11 Stunden ago | 0

| accepted

Answered
loop of linear combination of columns
Isn't it just theta = B*A;

etwa 12 Stunden ago | 0

Answered
How to put the solutions of a equation in a matrix (there are different solutions because variables are changeable), then find the wanted solutions with it's variables?
Try this a = [1 2 3]; b = [3 1 6]; [A, B] = ndgrid(a, b); A = A(:); B = B(:); x = 10*A + B; [x_min, idx] = min(x(x>...

etwa 12 Stunden ago | 0

| accepted

Answered
Why is this code not working whilst the other is?
You have written an 's' after end of the function. Nothing should come after the end keyword function sum = Sum3(x,y,z) s = 0;...

etwa 12 Stunden ago | 1

| accepted

Answered
Spectrum graph from sinusoidal signal in wavelength
This is a modified version of the example on MATLAB fft() documentation page. For this example, I assume wavelength = 1/f. And I...

etwa 13 Stunden ago | 0

| accepted

Answered
Trying to code a tricky double summation
Something like this should work s = 0; for i=0:min(x,y) for k=0:x-1 s = s + (-1)^k * D(2*x-2*k-2*i, 2*y+2-2*i) *...

etwa 14 Stunden ago | 1

| accepted

Answered
Using Display function in an easy way
Use fprintf(): https://www.mathworks.com/help/matlab/ref/fprintf.html S = 0.15; fprintf('S = %.2f\n', S)

etwa 14 Stunden ago | 1

| accepted

Answered
minimum value of one inequality
One way is to use optimization toolbox fmincon(@(n) n, 0, [], [], [], [], [], [], @nlcon) function [c, ceq] = nlcon(n) r = ...

etwa 15 Stunden ago | 2

Answered
How to change the transparancy (FaceAlpha) of single bars in a bar plot
It seems from the documentation that changing individual bars like this isn't currently supported. The workaround is to create e...

etwa 15 Stunden ago | 0

Answered
Why is my function not working?
Because you haven't defined the values of v and t inside the function. Change to something like this function z = z(x) v = 1; ...

etwa 15 Stunden ago | 1

Answered
searching for rows with repeated values in two matrix
I think you can directly apply findgroups on 2nd column of b C = findgroups(B{:,2})

etwa 16 Stunden ago | 0

| accepted

Answered
How can I rotate a part of a matrix
Try something like this rotated_matrix = original_matrix(:,:,:,[1:20 42:-1:21]);

etwa 19 Stunden ago | 0

Answered
output visualisation in matlab code
An easy way is to add breakpoints to your code: https://www.mathworks.com/help/matlab/matlab_prog/set-breakpoints.html and then ...

etwa 23 Stunden ago | 1

| accepted

Answered
error in creating a vector the spans the length of another vector
Each row of M corresponds to one value in a a = [1 2 3 4 5]; M = arrayfun(@(x) linspace(0, 7/x, 20), a, 'uni', 0); M = vert...

etwa 23 Stunden ago | 0

Answered
Make NaN value part of matrix
Do something like this x_planes = [1 30 60]; % x-planes to keep M = % 60x60x60x80 matrix M_new = M*nan; M_new(x_planes, :, :...

etwa 24 Stunden ago | 0

Answered
Column Vector Containing the Row Sums of the Elements of A
Why not use the builtin function M = rand(10, 5); M_sum = sum(M, 2) As for your current code, the correct is function RowSum...

ein Tag ago | 0

| accepted

Answered
trying to display a list of numbers
Why not primes(1000) https://www.mathworks.com/help/matlab/ref/primes.html or isprime(): https://www.mathworks.com/help/matl...

ein Tag ago | 0

| accepted

Answered
how to plot 3D using a txt file
I assume that first 3 columns are x, y, and z values. You need to use scatteredInterpolant data = readmatrix('chalitp.txt'); ...

ein Tag ago | 1

| accepted

Answered
getting an empty figure for line plot of sine function
Use element-wise division operator y = (sin(sin(pi*x))) ./ (pi*x); %^ use ./ instead of / Read here: http...

ein Tag ago | 0

Answered
How to save figures from a loop to current folder with specific names
Write saveas() line like this saveas(h, sprintf('T%db%d.png',T_A, b_A))

ein Tag ago | 1

| accepted

Answered
How do i get the values of a 2D matrix based on column indices ?
Use sub2ind() matrix = [1 2 3 4 5 6 7 8 9]; cols = [1 3 1]; idx = sub2ind(size(matrix), 1:size(...

ein Tag ago | 0

Answered
What is the meaning of command for(x:x1:x2) ?
The correct is for i = x:x1:x2 % any variable name can be used in place of i % The variable i takes value from vector x:x1...

ein Tag ago | 0

Answered
How can i connect these points that is basically act as transmitter and receiver. To connect one X with * individually
Something like this xx = 1000*rand(1, 100) - 500; yy = 1000*rand(1, 100) - 500; xr = xx + 30*rand(size(xx)); yr = yy + 30*...

ein Tag ago | 1

Answered
simple way to multiply varying parameter with matrice
Try this A = rand(2,2); param = 0:0.1:2; M = arrayfun(@(x) {x*A}, param); M = blkdiag(M{:}); It multiplies A with all val...

ein Tag ago | 0

Answered
'Array indices must be positive integers or logical values' error in my code
You missed multiplication operator (*) at several locations in the file test.m. Check the attached file and see the difference.

ein Tag ago | 0

Load more