plot - Matlab element-wise power - can't understand how it works -


i have matched filter, want plot frequency response in matlab.

the filter response is: h(f) = frequency response of wiener filter

i tried to plot with:

%freqency_response_of_wiener_filter f = linspace(-1e3,1e3,1e5); h = ((2*pi*f)^2+10^6)/(11*(2*pi*f)^2+10^6+10^4); plot(f,h); xlabel('f') ylabel('h(f)') 

which not working, giving me error of 'matrix dimensions must agree' kind. read 'element-wise power', seems fit need, , changed h to:

h = ((2*pi*f).^2+10^6)/(11*(2*pi*f).^2+10^6+10^4); 

this indeed plot something, not want :) tried also

h = ((2*pi)^2*f.^2+10^6)/(11*(2*pi)^2*f.^2+10^6+10^4); 

with no luck. way got working is:

%freqency_response_of_wiener_filter f = linspace(-1e3,1e3,1e5); i=1:length(f)   h(i) = ((2*pi*f(i))^2+10^6)/(11*(2*pi*f(i))^2+10^6+10^4); end plot(f,h); 

why 'element-wise power' not working me?

more - differenece between regular operation 'element-wise operation'? because, example, on here: an introduction matlab, there's plot:

a = 0:.01:5; b = cos(2*pi*a); plot(a,b) 

and one:

x = 2:.1:4; y = 1./x; plot(x,y) xlabel('x'); ylabel('y'); 

and can't tell difference between them. why on first 1 there no need of 'element-wise operation', while in second 1 there was?

thanks.

the reason why h = ((2*pi)^2*f.^2+10^6)/(11*(2*pi)^2*f.^2+10^6+10^4); did not work because need ./:

h = ((2*pi)^2*f.^2+10^6)./(11*(2*pi)^2*f.^2+10^6+10^4); 

in first case:

a = 0:.01:5; b = cos(2*pi*a); plot(a,b) 

you not need element-wise-operation because there 1 way of doing cosine of vector or matrix.

on other hand, in case:

x = 2:.1:4; y = x.^2; plot(x,y) xlabel('x'); ylabel('y'); 

you need specify want make element-wise operation rather multiplying matrix (that works square matrices).

in second case post:

x = 2:.1:4; y = 1./x; plot(x,y) xlabel('x'); ylabel('y'); 

you need . matlab understand 1 has vector of ones length numel(x).


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -