Attached are the plots of a i get from a csv file imported to MATLAB. I want to declutter the plot (remove the noise captured by measuring instrument) zoom on in the data.
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
Desired result capture.png
Accepted Answer
open('untitled2.fig')
xlim([-0.5 2.5]) % changed domain min and max to zoom in.

h=gca; % obtained handle of the current axes
x = h.Children.XData; % extracted xdata from figure
y = h.Children.YData; % extracted ydata from figure
y=lowpass(y,10,1000); % Low pass filter with cut off at 10Hz, assuming sample rate of 1000 Hz
plot(x,y)
xlim([-0.5 2.5]) % changed domain min and max to zoom in.

open('untitled.fig')

h=gca; % obtained handle of the current axes
x = h.Children.XData; % extracted xdata from figure
y = h.Children.YData; % extracted ydata from figure
y=lowpass(y,10,1000); % Low pass filter with cut off at 10Hz, assuming sample rate of 1000 Hz
figure
plot(x,y)
xlim([-20 20])

6 Comments
Now, if you want to just update the figures:
open('untitled2.fig')
xlim([-0.5 2.5]) % changed domain min and max to zoom in.
h=gca; % obtained handle of the current axes
y = h.Children.YData; % extracted ydata from figure
y=lowpass(y,10,1000); % Low pass filter with cut off at 10Hz, assuming sample rate of 1000 Hz
h.Children.YData = y;

open('untitled.fig')
h=gca; % obtained handle of the current axes
y = h.Children.YData; % extracted ydata from figure
y=lowpass(y,10,1000); % Low pass filter with cut off at 10Hz, assuming sample rate of 1000 Hz
h.Children.YData = y;
xlim([-20 20])

Sarthak Jakar
on 2 Mar 2022
Edited: Sarthak Jakar
on 2 Mar 2022
Hi @Kevin Holly
Can you please also tell how do i identify what part of data from the csv contribute to this plot?
Since there are 100000 reading taken in the csv file, i need to know what data points are contributing to the plot. so that i can extract that in to other excel file and do further calculation.
Kevin Holly
on 2 Mar 2022
Edited: Kevin Holly
on 2 Mar 2022
I read the data from the figure that you provided.
open('untitled2.fig')
xlim([-0.5 2.5]) % changed domain min and max to zoom in.
h=gca; % obtained handle of the current axes
y = h.Children.YData; % extracted ydata from figure
y=lowpass(y,10,1000); % Low pass filter with cut off at 10Hz, assuming sample rate of 1000 Hz
h.Children.YData = y;

You can find out the datapoints at the x limits I chose with the following:
x = h.Children.XData; % extracted ydata from figure
startpoint = find(x==-0.5)
startpoint = 49380
endpoint = find(x==2.5)
endpoint = 52380
From the data in our plot, I created the following plot from 49380 to 52380
plot(x(startpoint:endpoint),y(startpoint:endpoint))

@Kevin Holly okay got it, thanks..then i can use xlxwrite to save the start and end data point range in excel, right?
Yes, you could use xlswrite to save the data within that range.
new_x = x(49380:52380);
new_y = y(49380:52380);
You can save the variables new_x and new_y into the Excel sheet.
Ok thanks Kevin..you saved my day.
More Answers (0)
Categories
Find more on Data Exploration in Help Center and File Exchange
Products
Tags
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)