help with analysis currents measurement plot.

조회 수: 3 (최근 30일)
Freddy Belhasan
Freddy Belhasan 2020년 1월 16일
답변: Guru Mohanty 2020년 1월 25일
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
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)))
  댓글 수: 1
Freddy Belhasan
Freddy Belhasan 2020년 1월 24일
Hi, Claudio Iturra
First of all thank you very much for the help.
Your advice has been very helpful to me, and I would be happy if you could see my commend to
Guru Mohanty and help me with the problem also.

댓글을 달려면 로그인하십시오.


Guru Mohanty
Guru Mohanty 2020년 1월 22일
Hi, you can load data using textscan and plot the graph using plotfunction. Here is a sample code.
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));
current.jpg

Freddy Belhasan
Freddy Belhasan 2020년 1월 24일
편집: Freddy Belhasan 2020년 1월 24일
Hi
Hi Guru Mohanty,
First of all thank you very much for the help.
The code you wrote me is great I will just make my question more and what I need,
 I would be very happy if you could help me.
So, it is very important to me that the currents vector you define (C) will only have currents values (IMonL), so now there are values of voltage (VMon) which means 2900v or 2.900e+03 I want to filter all the voltage records (VMon) from the columnn no' 10 in the ' Hv text ' file and take only the Current records (IMonL) , I have no need for voltage measurements.
You can see which of the values is a current or voltage with column # 8 (IMonL, VMon).
And after I have the currents vector i would like to display the plot like the X axis is the time or number of tests (the number of (currents) for each current value and the Y axis will be the values of the currents.
Can you help me with that please?
  댓글 수: 1
Freddy Belhasan
Freddy Belhasan 2020년 1월 24일
편집: Freddy Belhasan 2020년 1월 24일
did you understand me?
Currently, I have received an output voltage of 2900 which is by in time.
And i'm less interesting voltage that is constant 2900 Throughout the experiment .
I want to get the currents dependent on time, the changes in the current by in time.
It will be excellent if it is possible to delete from the column of time and also from the column of currents any value that is voltage( (VMon) which means 2900v or 2.900e+03).

댓글을 달려면 로그인하십시오.


Guru Mohanty
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));
Capture.PNG

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by