Plotting points reshaping vector

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 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 10 月 25 日
what is staircase
T
T 2012 年 10 月 25 日
Sorry, I meant stairs( )

サインインしてコメントする。

 採用された回答

Star Strider
Star Strider 2012 年 10 月 25 日
編集済み: Star Strider 2012 年 10 月 25 日

0 投票

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 件のコメント

Star Strider
Star Strider 2012 年 10 月 25 日
編集済み: Star Strider 2012 年 10 月 25 日
The way I wrote it, yes:
Test2 = Tests(:,2);
I'm not quite sure I understand, however you could do the same reshape with your time vector, then plot Test1 against Time1 = Time(:,1), although I haven't actually run that.
Your Time and Test vectors are both [43 x 1], but I truncated them to [42 x 1] to get reshape to work correctly.
Star Strider
Star Strider 2012 年 10 月 29 日
編集済み: Star Strider 2012 年 10 月 29 日
Using the data you posted originally (with variables now named Time and wt) and using this code:
Tests = reshape(wt(1:end-1), [], 6);
Times = reshape(Time(1:end-1), [], 6);
Test1 = Tests(:,1);
Time1 = Times(:,1);
figure(2)
plot(Time1, Test1)
grid
I got no errors and the plot looked good. The Time1 and Test1 vectors (and all the others) are all [7x1] double vectors.
Star Strider
Star Strider 2012 年 10 月 29 日
編集済み: Star Strider 2012 年 10 月 29 日
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 2012 年 10 月 29 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeText Data Preparation についてさらに検索

タグ

質問済み:

T
T
2012 年 10 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by