Plot data from text file

2 Ansichten (letzte 30 Tage)
Izem
Izem am 23 Sep. 2020
Kommentiert: Rik am 23 Sep. 2020
I want to plot ReP^2+ImP^2 as function of numero = 5, 10, 15 …145 for each mode(m,n) I would like to have something like this with the name of the mode on each curve. Here is the beginning of my code, anyone can help ?
data = readfile(test.txt)
HeaderLines = 8;
for i=(HeaderLines+1):numel(tm)
%store in temp variable
if isempty(data{i}),continue,end
str=data{i};
line = str2num(str);
....
You can find my file attached.
Thank you in advance,
  5 Kommentare
Izem
Izem am 23 Sep. 2020
I already start doing exactly what you described before posting here but it will be long since I have many (m,n) (14 in this case) so I will need 14 if m == .. n ==.. I wonder if there is a shorter way to do it. I note that we can know the combinations from line 6 in the text file : 'VECTEUR MODE : 4 4 4 4 3 3 3 2 2 2 1 1 1 1' which mean that we will have :
4 modes starting with 0 : m=0 and n change from 1 to 4 (0 1, 0 2, 0 3, 0 4)
4 modes starting with 1 (1 1, 1 2, 1 3, 1 4)
...
1 mode starting with 13 (13, 1)
So please tell me if you think there is a smarter way to do it using line 6 ? otherwise I will do what you already suggested.
Rik
Rik am 23 Sep. 2020
You should convert the entire file. That means you will have a vector m with 5145 elements. Then you can use unique and use the result for a for loop, in which you can use ismember to extract all positions where m has a specific value.
You can also use that line to extract the values of m and n you need to combine.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by