Plotting points reshaping vector

2 vues (au cours des 30 derniers jours)
T
T le 25 Oct 2012
I have the following data:
Time:
1.0e+003 *
3.342911997609290
3.741319350087413
3.745865099431818
3.751175512500000
3.756657074404762
3.762397812500000
3.763880312500000
4.834881545572916
4.880983523026316
4.888107233173077
4.896319561607142
4.907109674479167
4.918652979166668
4.921389277664209
5.558132424107146
5.739458049342106
5.743779912500000
5.748123156250000
5.753904049342105
5.759695353693182
5.761057523026316
6.419015729005792
6.608815238425926
6.611463812500000
6.613701931547619
6.616536812500001
6.619482837918660
6.620186764112903
6.817307491566130
7.495817373106060
7.498681302280406
7.501837541271551
7.505586875000001
7.509355979166667
7.510209825816761
8.151473224137932
8.207401086693549
8.210311169921875
8.213447741071429
8.217154979166665
8.220919023071627
8.221859519396553
8.277030572443181
and
wt =
0.409999999581800
0.249999999745000
0.333999999659320
0.549999999439000
0.624999999362500
0.775999999208480
0.332999999660340
0.409999999581800
0.249999999745000
0.333999999659320
0.549999999439000
0.624999999362500
0.775999999208480
0.332999999660340
0.409999999581800
0.249999999745000
0.333999999659320
0.549999999439000
0.624999999362500
0.775999999208480
0.332999999660340
0.409999999581800
0.249999999745000
0.333999999659320
0.549999999439000
0.624999999362500
0.775999999208480
0.332999999660340
0.409999999581800
0.249999999745000
0.333999999659320
0.549999999439000
0.624999999362500
0.775999999208480
0.332999999660340
0.409999999581800
0.249999999745000
0.333999999659320
0.549999999439000
0.624999999362500
0.775999999208480
0.332999999660340
0
If one uses stairs(gwdTime,wt) you will see six different peaks. If I want to isolate each peak by 'Test #1' 'Test #2' and so on, how would I do this?
  2 commentaires
Azzi Abdelmalek
Azzi Abdelmalek le 25 Oct 2012
what is staircase
T
T le 25 Oct 2012
Sorry, I meant stairs( )

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 25 Oct 2012
Modifié(e) : Star Strider le 25 Oct 2012
If you want to isolate the data as individual test vectors, then I suggest:
Tests = reshape(wt(1:end-1), [], 6);
then:
Test1 = Tests(:,1);
and so for the others.
If you want to label them on the plot, I suggest:
spike_idx = find(wt >= 0.9*max(wt));
for k1 = 1:length(spike_idx)
TestLbl(k1,:) = sprintf('Test #%d',k1);
end
figure(1)
plot(gwdTime, wt)
for k1 = 1:length(spike_idx)
text(gwdTime((k1-1)*6+1), 0.75, TestLbl(k1,:), 'FontSize',6)
end
grid
  4 commentaires
Star Strider
Star Strider le 29 Oct 2012
Modifié(e) : Star Strider le 29 Oct 2012
I can't figure out exactly where you want the labels. The spikes seem to me to be the end of each test, so I initially wrote my code to put the labels before each spike.
See if this does what you want:
Tests = reshape(wt(2:end), [], 6);
Times = reshape(Time(2:end), [], 6);
That puts the spikes at the beginning of your tests. Restating the text line as:
text(Times(1,k1), 0.75, TestLbl(k1,:), 'FontSize',6)
will label each spike as a test.
Star Strider
Star Strider le 29 Oct 2012
I plotted the data you posted! I don't know if the spike is supposed to be at the start or end of the test. Since I have absolutely no idea what you're doing, I'm simply helping with the programming.
Use:
Tests = reshape(wt(1:end-1), [], 6);
Times = reshape(Time(1:end-1), [], 6);
instead of the others. I was experimenting with different ways to parse your data into six tests. Since you have 43 data pairs, that doesn't go as neatly as it otherwise might. The different tests all seem to have the same number of data, even though the times differ enough to make this a challenge.
These might be close to what you want. Put this line before figure(1):
dT = diff(Times,[],2);
spike_idx = [1; find(wt >= 0.9*max(wt))];
Then change the code to:
figure(1)
plot(Time, wt)
text(Times(1,1), 0.75, TestLbl(1,:), 'FontSize',6)
for k1 = 2:length(spike_idx)-1
text(Time(spike_idx(k1))+dT(k1)*0.25, 0.75, TestLbl(k1,:), 'FontSize',6)
end
grid
That's the best I can do.
As for the last data tapering down instead of plateauing — those data are what you posted.
I have no idea what you mean by ‘center the peak’. If you're talking about centering the labels over the data and avoiding the peaks, I did my best to do that.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur NaNs dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by