bandwidth from 2D array
1 次查看(过去 30 天)
显示 更早的评论
Hello,i have a 2D array of numbers, i need to take the peak value which always located at the same X=0 point and subtracts 3 and find the two points(positive X-axes and negative X axes) in this table which are the closest to these values.
for example if my value at x=0 is 7 then i need to find the two places int the Y axes which are closest to 4.
if if we have (-30,4.1) and (+32,4.3) then the bandwidth 30+32 is 62 i thought of running two parallel "for" one for positive axes one for negative axes and taking the closest point on each side by checking iteratively.
is there an easier way?
Thanks
回答(1 个)
KSSV
2017-2-17
clc; clear all ;
y = 2*sin(linspace(0,pi))' ;
x = [1:length(y)]' ;
p = [x y] ;
%%get maximum
[val,idx] = max(y) ;
% substract and add a value
dw = 0.2 ; % value to be substracted
y0 = val-dw ;
% get the nearest values
id = find(abs(y-y0)-dw <= 10^-3) ;
idx0 = id(1) ; idx1 = id(end) ;
% required points
p0 = [x(idx0) y(idx0)] ;
p1 = [x(idx1) y(idx1)] ;
% Bandwidth
BW = abs(x(idx0)-x(idx1)) ;
% plot
figure
hold on
plot(x,y,'r') ;
plot(x(idx), y(idx),'Or')
plot(p0(1),p0(2),'*g')
plot(p1(1),p1(2),'*b')
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!