Ideas on creating graph
    8 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
Hi, I have a dataset recorded in real time. The datasets range from 2 to 7 minutes and have large data in it. I wanted to plot them and see them. I used the normal plot function but the graph is very intact and that's not something I wanted to see. Is there any way I can plot those data like I recorded? i.e making a continuous graph and pausing it where ever I want to pause and see the behaviour?
0 commentaires
Réponses (1)
  Aashray
 le 28 Mar 2025
        Hello Sam,
Yes, you can create a dynamic, continuous plot that simulates real-time data recording, in which you can control the plotting of graph by pausing and resuming the plotting. The “pause()” function in MATLAB can be used to simulate a real-time plot, where the graph updates incrementally. 
You may refer to the following script for better understanding:
sampleData = rand(1000,1); 
time = 1:length(sampleData);
figure;
h = plot(time(1), sampleData(1), 'LineWidth', 2);
xlabel('Time');
ylabel('Data Value');
grid on;
% Update the plot incrementally
for i = 1:length(sampleData)
    % Update the data
    set(h, 'YData', sampleData(1:i), 'XData', time(1:i));  
    % Pause to simulate real-time behavior
    pause(0.1);  % You may adjust the time as per requirement
    % For pausing manually
    % (Eg. when you press a key or reach a specific time step)
    if mod(i, 100) == 0  % Eg:Pause every 100 points
        disp('Press any key to continue...');
        pause;  % This will pause the plotting, and will not resume plotting until you press some key in Command Window
    end
end
Also, I am attaching documentation links for the functions used:
0 commentaires
Voir également
Catégories
				En savoir plus sur Creating, Deleting, and Querying Graphics Objects 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!