Plot values of matching string
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi ,
I am running memory analysis test every 10sec on my Linux board and I need to plot the values of Usage of a certain process .
For Ex : , in the attached testme.txt , I need to search for string "Webkit" and get the Uss used by Webkit and plot them
In the given test file , it would be equivalent to plotting [88416, 27927] . Please note that the extra K needs to be eliminated
0 Kommentare
Antworten (1)
Sameer
am 7 Nov. 2024
Here's a sample script to extract the necessary data as per you requirement, and plot it:
% Read the contents of the text file
filename = 'testme.txt'; % Replace with your actual file path
fileContent = fileread(filename);
% Use a regular expression to find the lines with "Webkit" and extract the Uss values
pattern = '\s*\d+\s+\d+K\s+\d+K\s+\d+K\s+(\d+)K\s+Webkit';
matches = regexp(fileContent, pattern, 'tokens');
% Convert the extracted values from strings to numbers
ussValues = cellfun(@(x) str2double(x{1}), matches);
% Plot the values
figure;
plot(ussValues, '-o');
title('Uss Usage of Webkit Process');
xlabel('Sample Number');
ylabel('Uss (KB)');
grid on;
Please refer to the below MathWorks documentation link:
Hope this helps!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
