MATLAB Answers

help with analysis currents measurement plot.

18 views (last 30 days)
Freddy Belhasan
Freddy Belhasan on 16 Jan 2020
Answered: Guru Mohanty on 25 Jan 2020 at 13:28
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.

  1 Comment

Sign in to comment.

Answers (4)

Claudio Iturra
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)))

  1 Comment

Freddy Belhasan
Freddy Belhasan on 24 Jan 2020 at 15:46
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.

Sign in to comment.


Guru Mohanty
Guru Mohanty on 22 Jan 2020 at 4:37
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

  0 Comments

Sign in to comment.


Freddy Belhasan
Freddy Belhasan on 24 Jan 2020 at 15:43
Edited: Freddy Belhasan on 24 Jan 2020 at 16:00
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 Comment

Freddy Belhasan
Freddy Belhasan on 24 Jan 2020 at 15:47
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).

Sign in to comment.


Guru Mohanty
Guru Mohanty on 25 Jan 2020 at 13:28
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

  0 Comments

Sign in to comment.

Sign in to answer this question.

Tags