help with analysis currents measurement plot.
3 views (last 30 days)
Show older comments
Hello everyone,
I have a plot where it has columns where there are values of currents(last column ) measured from the power supply function of the time (first column).
I want to present the information as a plot of currents as a function of time,
Or displaying the currents in the function of the number of measurements.
Can someone please write me a code for this?
log txt plot (Hv_test) attached.
thanks a lot.
Answers (4)
Claudio Iturra
on 21 Jan 2020
Hello Freddy, I can help you with this.....
1) Use the function textscan to read your text file.
2) Separate each variable.
3) Create your vector time; time = datenum(year,month,day,hour,minute,second)
4) Create an index for each sensor
5) plot your data (if x is your variable, and you wanna plot your x valueas measured with the sensor 1)
plot(time(find(ind==1)),x(find(ind==1)))
Guru Mohanty
on 22 Jan 2020
clc;
clear all;
fid=fopen('Hv_test.txt');
C = textscan(fid,'[%d-%d-%dT%f:%f:%f]: %s %s %s %s %s %s %s %s [%.3f];');
fclose(fid);
time=[C{4} C{5} C{6}]; % Extract Hour Minute & Second
time_in_sec=time(:,1)*3600 + time(:,2)*60 + time(:,3); %time in Second
current=[C{15}];
pt=[time_in_sec current];
plot(pt(:,1),pt(:,2));
0 Comments
Guru Mohanty
on 25 Jan 2020
Hi Freddy, You can extract current values from the txt file by the help of find function of MATLAB.Here is the code for it.
clc;
clear all;
fid=fopen('Hv_test.txt');
C = textscan(fid,'[%d-%d-%dT%f:%f:%f]: %s %s %s %s %s %s %s %s [%.3f];');
fclose(fid);
current_Index = find(contains(C{13},'[IMonL]'));
time=[C{4} C{5} C{6}]; % Extract Hour Minute & Second
t_in_sec=time(:,1)*3600 + time(:,2)*60 + time(:,3); %time in Second
c=[C{15}];
current=c(current_Index);
time_in_sec=t_in_sec(current_Index);
pt=[time_in_sec current];
plot(pt(:,1),pt(:,2));
0 Comments
See Also
Categories
Find more on Text Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!