Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
i want to find H(z) in this code and print it.but i don't know how can i?
n=-11:11;
lp=(1/3)*sinc((1/3)*n);
wh=rectwin(23);
b=lp.*wh';
figure(1);
k=0:22;
stem(k,b);
title('N=23 FIR Filter impulse Response');
xlabel('Time');
ylabel('Mag');
figure(2);
[h,w]=freqz(b,1,1024);
plot(w/pi,20*log10(abs(h)));
grid;
title('LPF FIR -rectwin N=23 frequency response');
axis([0 1 -100 10]);
For a FIR filter with coefficients b(1), b(2), ..., the transfer function is the sum of b(k)*z^(-k+1) for k from 1 to len(b). See https://ccrma.stanford.edu/~jos/fp/FIR_Transfer_Function.html (The difference of +1 in the power of z is because Matlab arrays are indexed starting at 1, but the vector b in the link starts at b_0.)
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am doing a 5D data reconstruction from 5D noisy data. I am looking for any MATLAB codes or functions to calculate the SNR (in dB) in order to compare the noisy data with the original 5D data. Is there any way to do this using MATLAB?
Use: r = snr(x,y)
From Matlab documentation: r = snr(x,y) returns the signal-to-noise ratio (SNR) in decibels of a signal, x, by computing the ratio of its summed squared magnitude to that of the noise, y. y must have the same dimensions as x. Use this form when the input signal is not necessarily sinusoidal and you have an estimate of the noise.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have 1D vector. For example: y=[0.2 0.9 1.0 1.0]. I can plot it with plot(y) to get a graph of y(x) where x values are just indices [1, 2, 3, 4].
Now, instead of x values being just indices, I want to map them to [0,1] range: x = linspace(0,1,length(y)). I get: x=[0 0.3333 0.6667 1.000].
I can now make a graph with plot(x,y):
Now, however, I want an inverse graph, so I make a plot with plot(y,x):
I want to be able to now use plot(x) to get the same shape as above. However, if I use plot(x), as expected, I just get a straight line.
How to transform x in such a way that plot(x) will give the same shape as plot(y,x)?
Upd.: If I try just 1./x:
I have managed to find a solution, so for anybody who also need its:
x = linspace(0,1,length(y));
% not needed in this toy example, but can be required for a bigger vector:
[y_unique, idx] = unique(y);
inv_y = interp1(y_unique,x(idx),x);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I don't understand when to use the semilogx or semilogy function in Matlab and when to use the plot function,for example for displaying the spectrum of a signal
semilogx will scale the x-axis logarthmically, the same applies for semilogy on the y-axis. The data is exactly the same but sometimes it can be easier to view data where your axes are scaled like this. For example compare the two plots below.
x = [0.01 0.1 1 10 100 1e3 10e3];
subplot(121);
plot(x, '-o');
grid on;
subplot(122);
semilogy(x, '-o');
grid on;
You can access the documentation for any MATLAB function using help or doc as follows doc semilogx
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I have been working on Homomorphic speech coder I have obtained the cepstral coefficients of the signal and the next step I have been asked to perform is quantize the coefficients using adaptive quantizer. I am not sure how to quantize the coefficients as its value ranges from -1.5 to 1.5, if i quantise it I just get 0 and 1 which i'm sure is wrong. What is the right way to quantise it.
I think when you are being asked to quantize the coefficients, you are being asked to set a resolution and quantize to that resolution. For example if you are to quantize to a 32-bit number, this would mean you would divide your range into 2^32 bins and quantize your values into those bins. For example:
offset = 1.5;
input_range = 3;
output_range = 2^32
quantized_value = round((value + offset) / input_range * output_range);
If you are being asked to use an adaptive quantizer that would mean that the resolution of the bins would be dynamic or the output bit width is variable. You would need to do more work to find what your goals are if you are going to write an adaptive algorithm for the quantization.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
For certain measurements i need to obtain only the numeric value of the first principal component from the matrix. Can someone please tell me how do i go about it?
the most straight forward way is just to get the top eigenvector/value of your data's covariance matrix using eigs
say the data matrix x is N by D, or # of data by dimension of data
you can simply do
C = cov(X);
[V, D] = eigs(C, 1);
in fact, you can get the top k principal components by running
[V, D] = eigs(C, k);