Answered
How to rescale the y-axis of a histogram?
One approach: X = randn(1, 420); [N,edges] = histcounts(X, 'Normalization', 'probability'); xbar = edges(1:numel(N)) + mean(...

7 years ago | 2

| accepted

Answered
For Loop plot range of numbers
I cannot follow what you are doing. At the very least, the ‘A_1’ assignment needs to be: A_1(N,:) = ((1./M).*((2/(g1+1)).*(...

7 years ago | 0

Answered
zpk function does not work
Run these lines from your Command Window or a script: restoredefaultpath rehash toolboxcache then try what you did before ...

7 years ago | 0

Answered
FFT yields two-times the actual frequency
The problem appears to be the way the frequency axis (‘xaxis’) is computed. The limits should be ±Fn, where ‘Fn’ is the Nyquist...

7 years ago | 0

| accepted

Answered
I get an error saying 'Array indices must be positive integers or logical values' but i need my value to be a decimal. How do i work around this?
I cannot run your code, and I am not certain what you are doing. I do not see that you have defined ‘g’ anywhere, so that may...

7 years ago | 1

| accepted

Answered
Optical Transfer Function 3D Mesh
Try this: [X,Y] = meshgrid(-1:0.01:1); R = sqrt(X.^2 + Y.^2) + eps; Z = (2/pi)*((acos(R))-(R).*sqrt(1-(R).^2)); figure m...

7 years ago | 0

| accepted

Answered
How to write x as a function of f(x)?
The Symbolic Math Toolbox has the finverse function: syms x f(x) = (x^2 - 1); finv = finverse(f) producing: finv(x) = ...

7 years ago | 1

| accepted

Answered
How can I convert exp(-s*T) to z domain
This seems to work, however only for the state-space realisation: s = tf('s'); T = 42; ...

7 years ago | 0

Answered
Need to fix error "index exceeds the number of array elements"
The added parameter must be the third (or greater) argument: function xdot=func(t,x,w) and the ode45 call will then be: [t,...

7 years ago | 0

Answered
How can i obtain the frequency response for Savitzky-Golay filtering?
Try this instead: t = linspace(0, 10); y = sin(2*pi*t/5) + randn(size(t))/10; sgf = sgolayfilt(y, 3, 11); figure plot(...

7 years ago | 2

| accepted

Answered
How to view current time in matlab... Then select the Second's value and use it as an input
Two possibilities: dv = datevec(now); ht = rem(fix(dv(6)),2); out = char('head'.*(ht==0) + 'tail'.*(ht==1)) and: dt = rem...

7 years ago | 0

Answered
How to evaluate the performance of the bandpass filter
Use the freqz function with the second output: [f,d] = bandpass(y, fpass, fs); freqz(d) That will produce the Bode plot of...

7 years ago | 0

| accepted

Answered
Create multiple sub arrays in one line!
Try this: str = '(44) (hello) (good) ()'; out = regexp(str, '(?<=\()\w*(?=\))', 'match') producing: out = 1×3 ce...

7 years ago | 1

| accepted

Answered
Plotting multiple lines on same graph
You created a second figure object, so the hold call did not apply to it. You also misspelled ’initial’. This works: t =...

7 years ago | 0

| accepted

Answered
Hi, what is the meaning of grid(gca,'minor')
That may be relatively old (pre-R2014b) syntax. See Display Major and Minor Grid Lines.

7 years ago | 0

| accepted

Answered
tf toolbox not recognized function
I have no idea what you are doing. This works when I run it (in R2019b): s = tf('s'); transfer_function = (s^2 + 2*s + 5)/...

7 years ago | 1

Answered
How To Generate Non Repeating floating Random Numbers from 1 to 10
One option: v = rand(1, 100)*9+1; [L, H] = bounds(v) % Check producing (in this run): L = 1....

7 years ago | 0

| accepted

Answered
legend bar not visible
This is a problem with recent versions of AMD video drivers. The generally-accepted solution is: opengl('software') and if...

7 years ago | 6

| accepted

Answered
Plotting the values of a vector
Try this: A=[1 1.1; 1.1 1]; l = [2; 1]/3; B=[1.09 1.44; 1.44 0.99]; w=1; r=linspace(0,1,100); for k = 1:numel(r) p(:...

7 years ago | 0

| accepted

Answered
Error - Undefined function or variable
My apologies for not seeing this Question earlier. I am not certain what you want to do. Taking a guess, this runs without...

7 years ago | 0

| accepted

Answered
Generate array of y values, from the numerical solution of f(y)=x, where x is an array of numbers
There are likely at least two solutions because of the term. I did not exhaustively analyse the function. Try this: f = @...

7 years ago | 0

| accepted

Answered
Coding for different x-axis increments
Use the ‘f’ vector to define the 'XTick' locations: set(gca, 'XTick',f) Full code: g=[0 5 0 0 -10 100 -10 0 0 0 10 0 0 0 0 ...

7 years ago | 0

Answered
Error when plotting a graph
Use fplot if you have R2016a or later, ezplot otherwise.

7 years ago | 0

| accepted

Answered
Sum of both negative - positive part of a Peak
Try this: x = linspace(6.622, 9.644); y = exp(-(x-mean(x)).^2/0.5) - 0.1; Lv = y>=0; PosPart = trapz(x(Lv), y(Lv)) NegPa...

7 years ago | 1

| accepted

Answered
MATLAB matrices, vectors, and equations help!!!
The ‘CO’ variable is missing. If ‘CO’ is a row vector rathar than a column vector, that could be the problem. If so, the sol...

7 years ago | 1

| accepted

Answered
Returning only positive values of a data set
You cannot do exactly as you want, because the resulting matrix dimensions would not be compatible. Likely the best you can d...

7 years ago | 1

Answered
FIR filter using windowing method having specs
I have not found a universally-applicable method of calculating the order of a FIR filter. I generally begin with a 48-order F...

7 years ago | 1

Answered
Error using plot Vectors must be the same length
One option is to plot ‘z’ as a function of the lags xcorr computes: [z,lags] = xcorr(x1,y); subplot 223 stem(lags,z)

7 years ago | 0

Answered
Error - Vectors must be the same length
Your code does what you want it to, including the if block, and appears to produce the desired results: Mmax = 342....

7 years ago | 0

| accepted

Answered
Unable to perform assignment because the left and right sides have a different number of elements.
Since we do not know more about what you are calculating, the easiest way to deal with this problem is to create a cell array fo...

7 years ago | 0

| accepted

Load more