How to add text over my bar chart?

1 visualizzazione (ultimi 30 giorni)
TRISHITA BANERJEE
TRISHITA BANERJEE il 25 Lug 2018
Commentato: Aarti Dwivedi il 26 Lug 2018
I need to add text corresponding to the y axis in my current code..what extra should I add there?
fs = 48000;
L1 = 0.1 * fs;
L2 = 0.01 * fs;
K = 5;
w1 = 50 / fs;
w2 = 20e3 / fs;
c = log(w2/w1);
T = 1.5 * fs;
N = 5;
T_i = zeros(1,N);
ti_K = zeros(1,N);
T_MESM = zeros(1,N);
for n = 1:N
T_i(n) = ((n-1)*L1 + L2) * c/log(2); % sweep length for interleaving n sweeps
if T_i(n) < T
T_i(n) = T;
end
ti_K(n) = T_i(n)/c * log(K); % distance of IR to kth HIR
T_MESM(n) = T_i(n) + ti_K(n)*(N/n-1) + N*L1;
end
t_MESM = T_MESM/fs;
t_i = T_i / fs;
% optimal n
n_opt = ceil( (T*log(2))/(c*L1) + (L1+L2)/L1 );
figure;
for k = 1:N
bar(k,T_MESM(k)/fs);
hold on;
end
hold off; %grid on;
figure;
for k = 1:N
bar(k,T_i(k)/fs);
hold on;
end
hold off; %grid on;
rel_T = T_i(n_opt) / T;
rel_n = (1 + log(K)/c*(N/(n_opt-1)-1)) / (1 + log(K)/c*(N/n_opt-1));
  2 Commenti
TRISHITA BANERJEE
TRISHITA BANERJEE il 25 Lug 2018
Found a solution to my answer:
clear all close all
fs = 48000; % fstart = 55;%55; % fend = fs/2;%24100; %Possible values 20k and 24k % A = 0.04;%0.025; for 0.6m%0.6;%for 1m distance%0.7;%for1.5m % % L1 = 9350; % for -70 db % L2 = 2250; % W1=2*pi*f_start/fs; % W2=2*pi*f_end/fs; L1 = 0.1 * fs; L2 = 0.01 * fs; K = 5; w1 = 50 / fs; w2 = 20e3 / fs; c = log(w2/w1); T = 1.5 * fs; N = 5;
T_i = zeros(1,N); ti_K = zeros(1,N); T_MESM = zeros(1,N);
for n = 1:N T_i(n) = ((n-1)*L1 + L2) * c/log(2); % sweep length for interleaving n sweeps if T_i(n) < T T_i(n) = T; end ti_K(n) = T_i(n)/c * log(K); % distance of IR to kth HIR
T_MESM(n) = T_i(n) + ti_K(n)*(N/n-1) + N*L1;
end
t_MESM = T_MESM/fs;
t_i = T_i / fs;
% optimal n n_opt = ceil( (T*log(2))/(c*L1) + (L1+L2)/L1 );
figure; for k = 1:N y=T_MESM(k)/fs; bar(k,y); for i=1:numel(y) text(k(i),y(i),num2str(y(i),'%0.2f'),... 'HorizontalAlignment','center',... 'VerticalAlignment','bottom') end hold on; end hold off; %grid on;
figure; for k = 1:N y=T_i(k)/fs; bar(k,T_i(k)/fs); for i=1:numel(y) text(k(i),y(i),num2str(y(i),'%0.2f'),... 'HorizontalAlignment','center',... 'VerticalAlignment','bottom') end hold on; end hold off; %grid on;
% n = 4; % %%%%% Equation (14) from Paper %%%%% % b0 = L1 * (c-log(K)); % b1 = (L2-L1)/(c-log(K)) + N*L1*log(2*K); % b2 = (L2+L1) * N * log(K); % % T_paper = 1/log(2) * (b0*n + b1 + b2/n); % T_paper = T_paper / fs % % %%%%% My Equation %%%%% % a0 = L1 * (c-log(K)); % a1 = (L2-L1)*(c-log(K)) + N*L1*log(2*K); % a2 = N * log(K) * (L2-L1); % % T_paddy = 1/log(2) * (a0*n + a1 + a2/n); % T_paddy = T_paddy / fs
rel_T = T_i(n_opt) / T; rel_n = (1 + log(K)/c*(N/(n_opt-1)-1)) / (1 + log(K)/c*(N/n_opt-1));
Aarti Dwivedi
Aarti Dwivedi il 26 Lug 2018
Please put your solution as an answer.

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by