Plotting time series within a limit and without certain data points
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Mudasser Seraj
le 12 Avr 2020
Commenté : Mudasser Seraj
le 12 Avr 2020
Hi
I have attached the timeseries data ("long_pos.mat") which I plotted to get to get the following figure.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/283960/image.png)
I want to get the plot within ylim [0 600] and without the vertical lines(which are generated due to -150 values in the timeseries data). Can someone kindly help me with this? Thank you.
0 commentaires
Réponse acceptée
darova
le 12 Avr 2020
Here is the solution
load long_pos.mat
Y = simout_x.Data; % extract data
T = simout_x.Time; % extract time
Y(Y<0) = nan; % replace negative values with 'NaN'
plot(T,Y);
Plus de réponses (1)
Image Analyst
le 12 Avr 2020
Try this:
s = load('long_pos.mat')
simout_x = s.simout_x;
tsInfo = get(simout_x)
data = simout_x.Data;
% Replace -150 with nan so it won't plot.
data(data == -150) = nan;
t = simout_x.Time
for col = 1 : size(data, 2)
plot(t, data(:, col), '-', 'LineWidth', 2);
hold on;
end
xlabel('t', 'FontSize', 15);
ylabel('y', 'FontSize', 15);
ylim([0, 600]);
grid on
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/283966/image.png)
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!