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!