Community Profile

# Ameer Hamza

### Hong Kong Polytechnic University

2,540 total contributions since 2016

View all

Contributions in
View by

how can i normalize a plot
divide by signals by maximum value of EtRe. Something like this max_EtRe = max(Etre); EtRe_ = EtRe/max_EtRe; Etlm_ = Etlm/max...

2 hours ago | 0

Why legend something wrong
No need to call loglog and scatter seperately. loglog() can do both % clear;clc;close all; h = [0.05 0.025 0.0125 0.00625 0...

3 hours ago | 0

How can I write a function that replaces all of the multiples of eight or nine in a vector with seven, unless the multiple of eight or nine is also a multiple of seven.
Something like this x = 1:1000; mul7 = mod(x, 7)==0; mul8 = mod(x, 8)==0; mul9 = mod(x, 9)==0; mask = (mul8 | mul9) & (~m...

5 hours ago | 0

How can I save the final output in a matrix without manually save it on the image panel using patch?
Use getframe() to get the graphics as an image matrix x=[0 10 5]; y=[0 0 8.66]; patch(x,y,'white') set(gca,'Color','k','xti...

6 hours ago | 0

Evaluate definite integral numerically, where the function is indeterminate
If you have Symbolic toolbox, then you can try syms x Phi = 1; f(x) = x.*cosh(x)./( sinh(x).*(cosh(Phi*x)).^2 ); y = vpain...

6 hours ago | 1

| accepted

How to have a surf plot displayed in a GUI (not as an external figure).
You need to pass app.UIAxes to all the other functions too. Otherwise, they will also create a new figure window. surf(app.UIAx...

6 hours ago | 0

How to show the color changing while comparing with grid size
You can use rescale() function. Change the contourf() line to this contourf(x,y,rescale(phi.', 0, 1));

6 hours ago | 0

creating a function that reads into the directory
you also need to use dir() to get actual file names. Try this code % FilePrefix ='DynamicData'; FilePrefix ='test'; Directory...

6 hours ago | 0

Plotting two random vector
816 to 832 makes up 17 elements. So I guess the range should be 817 to 832. If the data is available in Table datatype, then you...

6 hours ago | 0

is it possible to use cell array to define Lb and Ub of genetic algorithm in Optimization Toolbox
Define lb and ub as simple vectors. For example nvars = 18; lb = zeros(1, nvars); ub = ones(1, nvars) Also you need to pass ...

7 hours ago | 0

tout (time) is not working
tout is only created after the simulation is complete. Therefore, you cannot use it as an input to gain. It seems that you want ...

9 hours ago | 0

How can I call sub-functions in the Main function
I haven't used MATLAB grader, but you should be able to call them like normal MATLAB functions. function main % name of main fu...

9 hours ago | 0

Set interval for colorbar
Try this intervals = 0:0.1:1; clrs = bone(2*numel(intervals)-2); colormap(clrs); colorbar

9 hours ago | 0

ODE symbolic Boundary conditions in respect to another variable
You are correct. The equation is displayed incorrectly. It seems like a bug. However, it seems that this bug only affects the di...

9 hours ago | 0

| accepted

Can't plot all the four points among the inputs given in an OR Gate.
The way you are using plot() does not make much sense here. Using scatter() with y as the color value will show the difference f...

11 hours ago | 0

Settin spacing between Y-axis
Use daspect() plot(rand(1,10)*10); daspect([1 5 1]) % 1 unit of x-axis is equal to 5 units of y-axis Alternatively, try plot...

11 hours ago | 1

How can one show variable values in legend of a plot?
Run this example T = 1:3; Legends = compose('Temp is %d', T); hold on; plot(rand(1,10)); plot(rand(1,10)); plot(rand(1,1...

13 hours ago | 0

How to take and integral of a matrix
You can integrate a constant matrix by simply multiplying it with the length of the interval. M = [1 2]; M_int = M*(12-0) How...

13 hours ago | 0

Displaying All the Related Items from an Input File
Try this str = fileread('test.txt'); str_words = cellfun(@(x) {strsplit(x, ' ')}, strsplit(str, '\n')); str_words = [vertca...

13 hours ago | 0

| accepted

Plotting multiple probability distribution plots in succession
Something like this M = rand(24, 200); % your matrix figure; for i=1:size(M,1) x = M(i, :); subplot(6, 4, i); ...

14 hours ago | 0

| accepted

Subs function does not work on symbolic expressions and functions
You are overwriting the symbolic variable 'm' with numeric value on line m = solve(norm([5/m, 3/m, 0]) == 4.32, m); and after...

14 hours ago | 0

Removing DC component at 0 HZ from acceleration data after fft
As described here: http://blog.originlab.com/how-to-remove-dc-offset-before-performing-fft try using a high-pass filter to remov...

14 hours ago | 0

| accepted

How to capitalize words in a string (matlab)
"strrep() function is banned here". What about regexprep in = 'Hello Mello Jello Mello Hello'; out = regexprep(in, {'hello', '...

14 hours ago | 0

How to plot with diferents colors
By default, the MATLAB axes only use seven colors to plot the lines. After that, the sequence is repeated if there are more then...

14 hours ago | 0

Giving names to cells
Use iscell() function if ~iscell(output{i}) Also, note that save() will not accept indexing like this 'output{i}'. You will ne...

14 hours ago | 0

Timeseries Plot Between a certain time interval
See the attached file (saved in R2020a) for one of the possible ways. It uses the MATLAB function block.

14 hours ago | 0

resistor with random variable number not working
There is no need to add randn(1) in the resistor value. As the documentation page mentions: https://www.mathworks.com/help/simrf...

14 hours ago | 0

Problems in solve iteratively calculation
If you look at the graph of this equation, you can see that it has two solutions in the interval [0 1]. syms dt2; f = (-2.4638...

15 hours ago | 0

| accepted