Repeating arrow in plot
Show older comments
Hi so im trying to plot those graphs but i get the arrows from the previous graph, how can i get rid of them?
Filter=sgolayfilt(new_data,3,31); % filter for smoothing the signal's noise.
%----PLOTTING---
subplot(212);
plot(NewTime,Filter);
subplot(211);
plot(NewTime,new_data,'b');
subplot(211);
grid on
xticks(0:3:15);
set(gca,'FontSize',12,'FontName','Ariel');
title("Interpulated data");
xlabel("Time [sec]");
ylabel("Acceleration [m/sec^2]");
subplot(212);
grid on
xticks(0:3:15);
set(gca,'FontSize',12,'FontName','Ariel');
title("Filtered signal");
xlabel("Time [sec]");
ylabel("Acceleration [m/sec^2]");
annotation("arrow", [0.2775 0.2988], [0.419 0.372])
annotation("arrow", [0.1787 0.1575], [0.437 0.39])
annotation("arrow", [0.8638 0.8775], [0.179 0.24])
%% section break
FrequencyDomain1=fftshift(fft(new_data)); % Transforming the interpulated data to frequency domain and creating it symmetrical aroud zero by phase shiffting.
Amplitude1=abs(FrequencyDomain1); % the data is complex and we want the "size" of the data at each point so we use absolute value to find the amplitude.
n1 = length(new_data);
FrequencyDomain2=fftshift(fft(Filter)); % Transforming the filtered data to frequency domain and creating it symmetrical aroud zero by phase shiffting.
Amplitude2=abs(FrequencyDomain2); % the data is complex and we want the "size" of the data at each point so we use absolute value to find the amplitude.
n2 = length(Filter);
fs=100; % sampling rate [Hz].
fshift1 = (-n1/2:n1/2-1)*(fs/n1); % Creating the frequency axis in order to ensure that each data point match the correct frequency.
fshift2 = (-n2/2:n2/2-1)*(fs/n2);
%---PLOTTING---
subplot(211);
plot(fshift1,Amplitude1);
subplot(212)
plot(fshift2,Amplitude2,'Marker', 'none');
subplot(211);
grid on
xticks(-50:10:50);
set(gca,'FontSize',12,'FontName','Ariel');
title("Frequency domain before filterring");
xlabel("Frequency [Hz]");
ylabel("Amplitude");
xlim([-14.9 14.0]);
ylim([-77 4268]);
subplot(212)
grid on
xticks(-50:10:50);
set(gca,'FontSize',12,'FontName','Ariel');
title("Frequency domain after filterring");
xlabel("Frequency [Hz]");
ylabel("Amplitude");
xlim([-14.9 14.0]);
ylim([-77 4268]);
hold off
Answers (1)
Voss
on 22 Dec 2022
Store the annotations in a variable:
annot = [ ...
annotation("arrow", [0.2775 0.2988], [0.419 0.372])
annotation("arrow", [0.1787 0.1575], [0.437 0.39])
annotation("arrow", [0.8638 0.8775], [0.179 0.24])
];
Then when you want to get rid of them, delete them:
delete(annot);
Or maybe don't create them in the first place?
Categories
Find more on Subplots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!