How to cut off part of the figure out after you filtered it

6 visualizaciones (últimos 30 días)
nam bui
nam bui el 12 de Feb. de 2021
Comentada: Image Analyst el 15 de Feb. de 2021
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
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(:))]);

Respuestas (1)

Image Analyst
Image Analyst el 12 de Feb. de 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 comentarios
nam bui
nam bui el 15 de Feb. de 2021
please let me know, what should I fix, I have attached the mat file. Thank you
Image Analyst
Image Analyst el 15 de Feb. de 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.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by