bandwidth from 2D array
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Risposte (1)
KSSV
il 17 Feb 2017
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 Commenti
Vedere anche
Categorie
Scopri di più su Multirate Signal Processing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!