help with analysis currents measurement plot.
3 次查看(过去 30 天)
显示 更早的评论
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.
回答(4 个)
Claudio Iturra
2020-1-21
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
2020-1-22
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 个评论
Guru Mohanty
2020-1-25
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!