MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

Matt
0

plot of specified data

Matt
さんによって質問されました 2012 年 12 月 15 日
Hello,
I've got a little problem with a plot i'd like to generate. Sadly, I couldn't figure out how to do it.
I have 3 Vectors a, b, and c. a is a time-vector, b is a signal strength and c is the number of the measuring location.
Now I'd like to plot all the signals of the different measuring locations over the time.
Another problem is, that the number of the measuring locations is not always the same. (I'd like them to appear in the plot at the right time and disappear if there are no data.)
example:
a=[1;1;1;1;2;2;2;3;3;3;3;4;4;4;4;4;5;5;5];
b=[20;21;22;24;20;22;24;21;19;20;22;23;24;19;23;19;24;23;22];
c=[2;5;1;3;1;3;2;3;4;5;2;1;2;3;4;5;4;3;2];
at sekond 1 is measured 20dB at location 2
at sekond 1 is measured 21dB at location 5
at sekond 1 is measured 22dB at location 1
at sekond 1 is measured 24dB at location 3
at sekond 2 is measured 20dB at location 1
I hope the problem is clear now, and would be grateful if you told me if it isn't.
Thanks for your help in advance!

  0 件のコメント

サインイン to comment.

1 件の回答

Loginatorist
回答者: Loginatorist
2012 年 12 月 15 日
編集済み: Loginatorist
2012 年 12 月 15 日
 採用された回答

a=[1;1;1;1;2;2;2;3;3;3;3;4;4;4;4;4;5;5;5];
b=[20;21;22;24;20;22;24;21;19;20;22;23;24;19;23;19;24;23;22];
c=[2;5;1;3;1;3;2;3;4;5;2;1;2;3;4;5;4;3;2];
hold all
for ii = 1:5 % Or unique(c(:).') if missing locations
idx = c==ii; % logical index into location.
plot(a(idx),b(idx)); % Plot a vs. b that matches loc.
end
xlabel('Time (s)')
ylabel('Signal Strength (dB)')
legend({'Loc 1';'Loc 2';'Loc 3';'Loc 4';'Loc 5'})

  1 件のコメント

Matt
2012 年 12 月 15 日
thats one nice, easy solution! i feel a little stupid now, but either way, thanks a lot! :)

サインイン to comment.



Translated by