필터 지우기
필터 지우기

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

조회 수: 7 (최근 30일)
nam bui
nam bui 2021년 2월 12일
댓글: Image Analyst 2021년 2월 15일
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(:))]);

답변 (1개)

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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by