bandwidth from 2D array

7 ビュー (過去 30 日間)
fima v
fima v 2017 年 2 月 17 日
回答済み: KSSV 2017 年 2 月 17 日
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
KSSV 2017 年 2 月 17 日
編集済み: KSSV 2017 年 2 月 17 日
Giving the data would help us to help you..

サインインしてコメントする。

回答 (1 件)

KSSV
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')

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by