How to cut off part of the figure out after you filtered it
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello, I'm trying to cut out part of my plot but I dont know how I could modify the script to cut it out and here is what I got so far after I apply a lowpass filter.
Thank you for your time
Ts = 0.01;
Fs = 1/Ts;
Fm = Fs/2;
Fc = 2;
N =10;
d = fdesign.lowpass('N,Fc',N,Fc,Fs);
designmethods(d);
Hd = design(d);
%fvtool(Hd)
%X is a variable form csv
%X1 is a variable from csv
output = filter(Hd,X);
output1 = filter(Hd,X1);
figure;
plot(X,X1,'-g');
hold on
plot(output, output1,'r');
hold off
legend('raw signal','filtered signal')
xlabel('SWA (deg)')
ylabel('SWT (N.m)')
title('SWA vs SWT')
grid on
figure
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/517917/image.png)
subplot(2,1,1)
plot(X,X1);
title('Original plot');
uiwait(msgbox('Select an x-value from which to crop','modal'));
[x_user ~] = ginput(1); % Let the user select an x-value from which to crop.
x(x>x_user) = [];
subplot(2,1,2);
plot(output, output1);
title('New plot with cropped values');
xlim([min(x(:)) max(x(:))]);
0 Kommentare
Antworten (1)
Image Analyst
am 12 Feb. 2021
You could just display from 100 on:
xlim([100, max(output1)]);
or you could remove everything less than x=100
startingIndex = find(x >= 100, 1, 'first');
output = output(startingIndex : end);
output1 = output1(startingIndex : end);
X = X(startingIndex : end);
X1 = X1(startingIndex : end);
Of course you could use max(x_user) instead of 100 if you want.
8 Kommentare
Image Analyst
am 15 Feb. 2021
Look, sample.mat does not have a "current" variable stored in it.
sample = load('sample.mat')
sample =
struct with fields:
sample: [1500×2 table]
Reference to non-existent field 'current'.
Error in test6 (line 10)
X = sample.current;
You need to use a .mat file that has both current and sample variables in it.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!