How can I plot sequential data of a matrix

1 visualizzazione (ultimi 30 giorni)
Hello, I've derived my data from a software and it gives the data in a sequential format. It's a 2-column matrix in which the first column is X and the second one is Temperature of that point. X starts from 0 to 0.2, then I have another 0 to 0.2 and this pattern repeats. The first X from 0 to 0.2 and its pertaining T are corrosponding values for first time step and the next one is for the next time step, ... . The number of rows are not fixed for every iteration and total number of rows are unknown. I want to plot X vs T for every time step. Does anyone have an idea for defining the matrix?
0 329.62
0.01 329.61
0.014 329.60
0.2 329.59
0.00 329.63
0.05 329.62
0.10 329.64
0.15 329.68
0.20 3295
0 329
...

Risposta accettata

Star Strider
Star Strider il 18 Apr 2021
Try this:
A = [0 329.62
0.01 329.61
0.014 329.60
0.2 329.59
0.00 329.63
0.05 329.62
0.10 329.64
0.15 329.68
0.20 329.5
0 329];
is0 = find(A(:,1) == 0);
for k = 1:numel(is0)-1
idxrng = is0(k):is0(k+1)-1
segment{k} = A(idxrng,:);
end
figure
hold on
for k = 1:numel(segment)
plot(segment{k}(:,1), segment{k}(:,2), '.-')
end
hold off
grid
xlabel('X')
ylabel('T')
I have no idea how robust it will be for the full data set, however it works on the sample posted.
  8 Commenti
Amir Mohammadi
Amir Mohammadi il 19 Apr 2021
That's awesome. As always, Thank you!
Star Strider
Star Strider il 19 Apr 2021
As always, my pleasure!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by